Execute JS using Python and store results in an array - javascript

I am working on this website where there is an SVG map and radio buttons as filters :
To get the result of the filter in the map (countries colored in blue), I execute this javascript snippet :
var n = $("input[name=adoptionStatus]:checked").val();
(n == undefined || n === "") && (n = "00000000000000000000000000000000");
$(".status-text").hide();
$("#" + n).show();
$("#vmap").vectorMap("set", "colors", resetColorsData);
resetColorsData = {};
colorsData = {};
$("#countries_list a").each(function(t, i) {
$(i).data("adoption-status").indexOf(n) >= 0 && (colorsData[$(i).data("country-code")] = "#2f98cb", resetColorsData[$(i).data("country-codecountry-code")] = "#fefefe")
});
$("#vmap").vectorMap("set", "colors", colorsData)
The variable n is used to store the value of the radio button like in this case cae64c6b731d47cca7565b2a74d11d53 :
<div class="map-filter-radio radio">
<label>
<input type="radio" name="adoptionStatus" alt="IFRS Standards are permitted, but not required, for use by at least some domestic publicly accountable entities, including listed companies and financial institutions." title="IFRS Standards are permitted, but not required, for use by at least some domestic publicly accountable entities, including listed companies and financial institutions." value="cae64c6b731d47cca7565b2a74d11d53">
IFRS Standards are permitted but not required for domestic public companies
</label>
</div>
When I execute the Javascript in the console and try to get the colorsData, I get the list of the countries colored in blue like below :
bm: "#2f98cb"
ch: "#2f98cb"
gt: "#2f98cb"
iq: "#2f98cb"
jp: "#2f98cb"
ky: "#2f98cb"
mg: "#2f98cb"
ni: "#2f98cb"
pa: "#2f98cb"
py: "#2f98cb"
sr: "#2f98cb"
tl: "#2f98cb"
How can I execute the JS script on the webpage and get the result of the colored countries in an array using python ?

By looking at the list of countries specified by #countries_list, you got a list of a tag like the following :
<a id="country_bd" data-country-code="bd" data-adoption-status="97f9b22998d546f7856bb1b4f0586521|3adc18f07ff64c908a6d835e08344531|ff784361818644798ea899f81b8b6d61" href="/use-around-the-world/use-of-ifrs-standards-by-jurisdiction/bangladesh/">
<img src="/-/media/7bfd06a698594c2cb3614578a41caa9e.ashx" alt="Bangladesh">
Bangladesh
</a>
The data-adoption-status attribute is a list of adoptionStatus delimited by |.
You just need to split them and match only the countries that reference the value from the input adoptionValue like this :
if selectedAdoptionStatus in t["data-adoption-status"].split("|")
The following code lists all input tag and extracts the adoptionStatus for each one of these, it prompts user to choose a filter (0 to 4) and gets the selected countries by filtering on the data-adoption-status attribute :
import requests
from bs4 import BeautifulSoup
r = requests.get("https://www.ifrs.org/use-around-the-world/use-of-ifrs-standards-by-jurisdiction/")
soup = BeautifulSoup(r.text, "html.parser")
choiceContainer = soup.find("div", {"class":"map-filters"})
choices = [
(t["title"], t["value"])
for t in choiceContainer.findAll("input")
]
for idx, choice in enumerate(choices):
print(f"[{idx}] {choice[0]}")
val = input("Choose a filter index : ")
choice = choices[int(val)]
print(f"You have chosen {choice[0]}")
selectedAdoptionStatus = choice[1]
countryList = soup.find("div", {"id":"countries_list"})
selectedCountries = [
{
"countryCode": t["data-country-code"],
"adoptionStatus": t["data-adoption-status"].split("|"),
"link": t["href"],
"country": t.find("img")["alt"]
}
for t in countryList.findAll("a")
if selectedAdoptionStatus in t["data-adoption-status"].split("|")
]
for it in selectedCountries:
print(it["country"])
run this code on repl.it
Sample output
[0] IFRS Standards are required for use by all or most domestic publicly accountable entities.
[1] IFRS Standards are permitted, but not required, for use by at least some domestic publicly accountable entities, including listed companies and financial institutions.
[2] IFRS Standards are required or permitted for use by foreign securities issuers.
[3] In most cases an SME may also choose full IFRS Standards. In some cases, an SME may also choose local standards for SMEs.
[4] The body with authority to adopt financial reporting standards is actively studying whether to adopt the <em>IFRS for SMEs</em> Standard.
Choose a filter index : 1
You have chosen IFRS Standards are permitted, but not required, for use by at least some domestic publicly accountable entities, including listed companies and financial institutions.
Bermuda
Cayman Islands
Guatemala
Iraq
Japan
Madagascar
Nicaragua
Panama
Paraguay
Suriname
Switzerland
Timor-Leste

Related

Is it possible to format my json file for a Yes or No chat flow for my chatbot

I'm currently trying to create a chatbot as an IT support for FAQs on IT Department.
Since every computer problems have more than 1 solution, is there anyway I could format my json file in such a way that the conversation could flow like this:
Chatbot : Hello, what can I do for you?
User: My Wi-Fi keeps disconnecting
Chatbot: Solution 1: Click on the Network & Internet icon in the
system....(Please type Y if this solved your problem, and Type N if
No)
User: No
Chatbot; Soution 2: DISABLE WIFI SENSE. Click on the Windows icon in
your taskbar...(Please type Y if this solved your problem, and Type N
if No)
User: Yes
Chatbot: Glad I could help.
here's my sample code below
#Python
import random,json,pickle,numpy as np,nltk
from nltk.stem import WordNetLemmatizer
from tensorflow.keras.models import load_model
# import tech_supp._sample_chatbot.nlp.training
__my_file_path = 'tech_supp/python/chatbot/nlp/'
lemmatizer = WordNetLemmatizer()
intents = json.loads(open(f'{__my_file_path}intents.json').read())
words = pickle.load(open(f'{__my_file_path}words.pkl', 'rb'))
classes = pickle.load(open(f'{__my_file_path}classes.pkl', 'rb'))
model = load_model(f'{__my_file_path}chatbotmodel.h5')
def clean_up_sentence(sentence):
sentence_words = nltk.word_tokenize(sentence)
sentence_words = [lemmatizer.lemmatize(word) for word in sentence_words]
return sentence_words
def bag_of_words(sentence):
sentent_words = clean_up_sentence(sentence)
bag = [0] * len(words)
for w in sentent_words:
for i,word in enumerate(words):
if word == w:
bag[i]=1
return np.array(bag)
def predict_class(sentence):
bow = bag_of_words(sentence)
res = model.predict(np.array([bow]))[0]
ERROR_THRESHOLD = 0.80
results = [[i,r] for i,r in enumerate(res) if r>ERROR_THRESHOLD]
results.sort(key=lambda x:x[1],reverse= True)
return_list = []
for r in results:
probability = round(r[1] * 100,ndigits=2)
probability = str(probability)+'%'
return_list.append({'intent':classes[r[0]],'probability':probability})
return return_list
def get_response(message):
intents_list = predict_class(message)
# for each_intent_list in intents_list:
# print(each_intent_list)
if len(intents_list)>0:
tag = intents_list[0]['intent']
accuracy = intents_list[0]['probability']
else:
#fallback message
return "I'm sorry I don't understand you."
list_of_intents = intents['intents']
for i in list_of_intents:
if i['tag'] == tag:
# return f'Accuracy: "{accuracy}" {random.choice(i["responses"])}'
return random.choice(i["responses"])
print('Go! Bot is running!')
#Javascript
function open_chatbot(){
document.getElementById("chatbot").innerHTML =
`<div>
<button class="btn btn-outline-info" onclick="minimize_chatbot()">Minimize</button>
<label>Was this chatbot helpful?</label>
<button class="right-msg btn btn-outline-info" onclick="save_chat_session('yes')">Yes</button>
<button class="right-msg btn btn-outline-info " onclick="save_chat_session('no')">No</button>
<div class="msger-chat"></div>
<form class="msger-inputarea">
<input type="text" class="msger-input" id="textInput" placeholder="Enter your query...">
<button type="submit" class="msger-send-btn">Send</button>
</form>
</div>`;
const msgerForm = get(".msger-inputarea");
const msgerInput = get(".msger-input");
const msgerChat = get(".msger-chat");
//Icons made by Freepik from www.flaticon.com
const BOT_NAME = "Jayvee";
const PERSON_NAME = "You";
msgerForm.addEventListener("submit", event =>
{
event.preventDefault();
const msgText = msgerInput.value;
if (!msgText) return;
appendMessage(PERSON_NAME, "right", msgText);
msgerInput.value = "";
botResponse(msgText);
});
function appendMessage(name, side, text)
{
//Simple solution for small apps
const msgHTML =
`
<div class="msg ${side}-msg">
<div class="msg-img"></div>
<div class="msg-bubble">
<div class="msg-info">
<div name="message-name" class="msg-info-name">${name}</div>
<div name="message-datetime" class="msg-info-time">${formatDate(new Date())}</div>
</div>
<div name="message-text" class="msg-text">${text}</div>
</div>
</div>
`;
msgerChat.insertAdjacentHTML("beforeend", msgHTML);
msgerChat.scrollTop += 500;
}
function botResponse(rawText) {
// Bot Response
$.get("/chat", { msg: rawText }).done(function (data)
{
const msgText = data;
appendMessage(BOT_NAME, "left", msgText);
});
}
// Utils
function get(selector, root = document)
{
return root.querySelector(selector);
}
//chabot introduction
appendMessage(BOT_NAME, "left", "Hello! I\'m Jayvee your computer technical-support Chatbot.");
}
function minimize_chatbot(){
document.getElementById("chatbot").innerHTML =
'<button class="btn btn-outline-info" onclick="open_chatbot()">Chatbot</button>';
}
function formatDate(date){
var hour = date.getHours();
var minute = date.getMinutes();
if(hour==0)
hour=12;
var ampm = "AM";
if( hour > 12 ) {
hour -= 12;
ampm = "PM";
}
hour = "0" + hour;
minute = "0" + minute;
return `${hour.slice(-2)}:${minute.slice(-2)} ${ampm}`;
}
function save_chat_session(result){
/*
* result
* name
* datetime
* message
*/
let name= document.getElementsByName("message-name");
let datetime= document.getElementsByName("message-datetime");
let message= document.getElementsByName("message-text");
let conversation=[];
for (let i = 0; i < name.length; i++) {
let obj = {
"name":name[i].innerHTML,
"datetime":datetime[i].innerHTML,
"message":message[i].innerHTML
}
conversation.push(obj);
}
fetch('/admin/chatbot/save_session',{
headers: {'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify(
{
"result": result,
"conversation":conversation
}
)
})
.then(function (response) {return response.text();})
.then(function (text) {console.log('POST response: '+text);});
minimize_chatbot();
}
minimize_chatbot();
#Excerpt from my JSON FILE
{
"intents": [
{
"tag": "greetings",
"patterns": [
"hello",
"hey",
"hi",
"good day",
"Greetings",
"what's up?",
"how is it going?"
],
"responses": [
"Hello, Welcome to Our IT Chatbot",
"Good to see you, Welcome to our IT Chatbot",
"Hi there, how can I help?"
]
},
{
"tag": "Cannot access email",
"patterns": [
"can't access email",
"email inaccessible",
"cannot acess email"
],
"responses": [
"1.Restart the e-mail application. Log in with your credentials <br> 2.Try accessing your e-mail through the web. If you can access it, the problem lies in the application\u00e2\u20ac\u2122s software.<br> 3.Check the service status for any general e-mail issues.<br> If the solution given above didn't solve your problem, please contact your IT department or an IT expert for greater assistance!"
]
},
{
"tag": "Slow downloading and uploading speeds",
"patterns": [
"slow download speed, download slow",
"slow download",
"internet download slow",
"slow internet"
],
"responses": [
"Try running a speed test online. Ideally, you should get half of the speed that your service provider is claiming to offer.<br>If the tests are positive, double-check the background for any hidden files that are downloading or uploading <br> Also, check whether the network card needs updating or not. <br> 2.If slow speed still occurs, try resetting the modem to solve the network problems.<br> If the issue is not resolved, call your service provider to check if they are having problems from their end. <br> If you're connecting wirelessly, then the location may be the problem. The signal is not necessarily strong in all corners of the building. Similarly, you could just be too far away. If this is not the issue, then spyware or viruses are a likely cause. <br> If the solution given above didn't solve your problem, please contact your IT department or an IT expert for in-depth assistance!"
]
},
{
"tag": "Windows takes a long time to start",
"patterns": [
"windows starts slow",
"pc starts slow",
"turning on pc loads slow",
"slow startup"
],
"responses": [
"1.Disable Fast Startup-open Settings and browse to System then click Power & sleep. <br> On the right side of this screen, click Additional power settings to open the Power Options menu in the Control Panel and untick Turn on fast startup click Save.<br> <br> 2.Adjust Paging File Settings- Click Start Menu, choose the Adjust the appearance and performance of Windows. Under the Advanced tab, click Change. Uncheck Automatically manage paging file size for all drives then choose Custom Size and set the Initial Size and Maximum Size then Restart your computer.<br> <br> 3.Update Graphics Drivers- Open the Device Manager by right-clicking on the Start button (or hitting Win + X) and choose Device Manager. Go to Display adapters to see which graphics card you're using (others are Nvidia or AMD).Install any new version <br> If the solution given above didn't solve your problem, please contact your IT department or an IT expert for greater assistance! "
]
},
{
"tag": "How to fix lag on a PC",
"patterns": [
"How to fix lag on a PC",
"lag pc",
"solutions for lag pc"
],
"responses": [
"Solution 1: Run Disk Defragmenter.<br> Step 1: Press the Windows button. Click *All Programs* and open *Accessories*.<br> Step 2: Right-click *Command Prompt*. Choose *Run as Administrator*.<br> Step 3: Type *defrag X: -v* in the prompt, X representing the letter of your hard disk. For instance, if you want to defrag drive E type *defrag E: -v* in the prompt. Press *Enter*.<br> Step 4: Wait for the defragmentation to complete. Reboot your system once it is complete.<br><br> Solution 2: Run Disk Cleanup<br> Step 1: Press the Windows button. Type *Disk Cleanup* in the *Start Search* field. Press *Enter*.<br>Step 2: Click *My Files Only* when the Disk Cleanup Options prompt appears.<br> Step 3: Choose the drive and click *OK*. Allow the tool to scan for possible space to free up.<br>Step 4: Place a check by the files you want to delete. Click *OK*.<br> Step 5: Click *Delete Files* when the *Are You Sure You Want To Permanently Delete These Files?* prompt launches.<br> <br> Solution 3: Scan for Harmful Software<br>Step 1: Press the Windows button. Click *All Programs* and open *Windows Defender*.<br>Step 2: Click the *Scan* option toward the top of the window.<br> Step 3: Choose the repair option once the scan is complete. Reboot your system once the repair is complete.<br> If the solution given above didn't solve your problem, please contact your IT department or an IT expert for in-depth assistance!"
]
}
]
}
Thanks in advance!

How to parse an XML object in Javscript

This is probably a relatively simple problem but I am finding it difficult to be able to parse my specific xml object in javascript.
My XML looks like this
<ns2:GetItemResponse xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
<Ack>Success</Ack>
<Build>E1125_INTL_API_19070421_R1</Build>
<Item>
<AutoPay>false</AutoPay>
<BuyItNowPrice>0.0</BuyItNowPrice>
<BuyerProtection>ItemIneligible</BuyerProtection>
<Charity>
<CharityID>1135</CharityID>
<CharityName>The Humane Society of the United States</CharityName>
<CharityNumber>1726</CharityNumber>
<DonationPercent>10.0</DonationPercent>
<LogoURL>https://i.ebayimg.com/00/s/NzYyWDEzNzM=/z/K3EAAOSwFgNdVeRz/$_1.JPG?set_id=8800005007
</LogoURL>
<Mission>
The Humane Society of the United States is the nation's most effective animal protection organization. Since 1954, HSUS has been fighting for the protection of all animals through advocacy, education and hands-on programs. Together with our affiliates, we rescue and care for tens of thousands of animals each year, but our primary mission is to prevent cruelty before it occurs. We're there for all animals!
</Mission>
<Status>Valid</Status>
</Charity>
<Country>US</Country>
<Description>
<p dir="ltr">Wolverine #100 - April 1996 Marvel Comics The 100th Issue! Comic Book. </p>
</Description>
</Item>
<Timestamp>2020-02-13T14:19:33.939Z</Timestamp>
<Version>1125</Version>
</ns2:GetItemResponse>
I basically want to display the Item properties and Charity properties but I am finding it difficult to understand the child nodes of these objects I have tried doing this
parser = new DOMParser();
var obj = request.responseXML;
console.log(obj.getElementsByTagName("Item")[0]);
xmlDoc = parser.parseFromString(request.responseText, "text/xml");
// panel.innerHTML += "<br> " + xmlDoc.getElementsByTagName("ItemId")[0].childNodes[0].nodeValue ;
//console.log(xmlDoc.getElementsByTagName("Timestamp")[0].childNodes[0].nodeValue);
console.log(xmlDoc.getElementsByTagName("Item")[0].childNodes);
All help would be greatly appreciated
simple...
const docXML = `
<ns2:GetItemResponse xmlns:ns2="urn:ebay:apis:eBLBaseComponents">
<Ack>Success</Ack>
<Build>E1125_INTL_API_19070421_R1</Build>
<Item>
<AutoPay>false</AutoPay>
<BuyItNowPrice>0.0</BuyItNowPrice>
<BuyerProtection>ItemIneligible</BuyerProtection>
<Charity>
<CharityID>1135</CharityID>
<CharityName>The Humane Society of the United States</CharityName>
<CharityNumber>1726</CharityNumber>
<DonationPercent>10.0</DonationPercent>
<LogoURL>https://i.ebayimg.com/00/s/NzYyWDEzNzM=/z/K3EAAOSwFgNdVeRz/$_1.JPG?set_id=8800005007
</LogoURL>
<Mission>
The Humane Society of the United States is the nation's most effective animal protection organization. Since 1954, HSUS has been fighting for the protection of all animals through advocacy, education and hands-on programs. Together with our affiliates, we rescue and care for tens of thousands of animals each year, but our primary mission is to prevent cruelty before it occurs. We're there for all animals!
</Mission>
<Status>Valid</Status>
</Charity>
<Country>US</Country>
<Description>
<p dir="ltr">Wolverine #100 - April 1996 Marvel Comics The 100th Issue! Comic Book. </p>
</Description>
</Item>
<Timestamp>2020-02-13T14:19:33.939Z</Timestamp>
<Version>1125</Version>
</ns2:GetItemResponse>`;
const parser = new DOMParser()
, xmlDoc = parser.parseFromString(docXML, "text/xml");
console.log( '1st CharityName = ', xmlDoc.querySelector('Item CharityName').textContent )
.as-console-wrapper { max-height: 100% !important; top: 0; }

Display break tags in Jade Mixin

I have a JSON file that is being called inside of a Jade Mixin to display text. However, I need to insert a break tag in one of the JSON fields and don't know how to accomplish this inside the Jade Mixin. I can't seem to find the relevant information anywhere.
Here's the JSON file:
"features": {
"employers": {
"title": "For Employers",
"description": "Company corporate financial wellness program is designed to help employers lessen financial stress in the workplace, increase retirement readiness, and strengthen workplace culture.<br />Company offers a holistic approach to corporate financial wellness.",
"featureList": [
{
"iconSlug": "puzzle",
"title": "Easy Implementation",
"description": "Company provides a robust, custom marketing and communication plan to help drive program awareness and engagement."
},
{
"iconSlug": "rays",
"title": "Ongoing Engagement",
"description": "Get metrics around your employees’ engagement with the program and workplace impact."
},
{
"iconSlug": "dollarSign",
"title": "Affordable Pricing",
"description": "Explore our pricing options for all company sizes, including low, per- employee rates that can be paid out of ERISA budgets."
}
],
"cta": {
"title": "Contact our team",
"class": "trigger-emailFormScroll"
}
}
And Here is the Mixin that pulls it in:
mixin FeaturesModule(config)
h3.lvHeading.lvHeading-size3.lvHeading-main= config.title
h5.lvHeading.lvHeading-size5= config.description
- if (config.cta && typeof config.cta.newPage === "undefined") { config.cta.newPage = true; }
.layout-stdGrid
each feature, i in config.featureList
.stdGrid-col8.stdGrid-col-thin.padding-2
abbr(class= "icon-mktgLight-" + feature.iconSlug)
h6.lvHeading.lvHeading-size5.lvHeading-main!= feature.title
span.block= feature.description
- if (config.featuredLink)
a.link-featured.margin-Y-1.block(href= config.featuredLink.href, name=config.featuredLink.title, target= "_blank")= config.featuredLink.title
- else if (config.cta)
- if (config.cta.href)
a.button.button-wide(href= config.cta.href, target= (config.cta.newPage) ? "_blank" : undefined)= config.cta.title
- else
- var ctaClass = config.cta.class || "";
button.button.button-wide(class= ctaClass)= config.cta.title
The span.block = feature.description is what I'm working with at the moment. What is the best way of making the mixin interpret the break tag so it's not printing on the page as text?
Thanks in advance.
Both solution will work:
span.block!=feature.description
span.block!{feature.description}

jQuery Tablesorter File Size in Rails App

So all of my columns sort without issue, except for my Media column which displays quotas for file size limits (GB, TB, etc.) I suspect the Rails NumberHelper number_to_human_size isn't playing nicely with tablesorter. Anyone have an idea how to get it to sort, while utilizing the NumberHelper?
_table.html.haml
%table#myTable.tablesorter
%thead
%tr
%th Name
%th.right Per Month
%th.right Members
%th.right Additional
%th.right Media
%th.right Subscriptions
- if #plans.any?
%tbody
- #plans.each do |plan|
%tr
%td
= link_to admin_plan_path(plan) do
= plan.name
%td.right
= "$ #{plan.base_price_in_cents / 100}"
%td.right
= plan.included_users
%td.right
= "$ #{plan.price_in_cents / 100}"
%td.right
= number_to_human_size(plan.media_data_quota) || '∞'.html_safe
%td.right
= link_to organizations_admin_plan_path(plan) do
= plan.subscriptions.count
application.js
$(document).ready(function()
{
$("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} );
}
);
To make file sizes sort properly, you'll need a parser to convert "GB" and "TB", etc, into sortable numbers.
There is a metric parser available on my fork of tablesorter - demo which converts both metric & binary values to make sorting work.
To use it, load the parser file, then add a sorter-metric and data-metric-name attribute:
<th class="sorter-metric" data-metric-name="b|byte">Media</th>
I haven't tested it, but if you are using the original tablesorter, this parser should still work. If that is the case, the sorter class name won't work, so you'll need to set the headers option:
headers: {
0 : { sorter: 'metric' }
}

how do I omit a line when field is empty (using mustache/handlebars)

i'm currently using mustache and trying to implement some basic if-else checking. In my case, I'm checking for a value in a field.
for example:
I have this JSON data:
"AGENCIES":[
{
"IASTATE":"Buenos Aires",
"IAADDRESS1":"Paraguay 647 Piso 4 Of. 17\/18",
"IAADDRESS3":"",
"IALEGALNAME":"Silvia Stocker Australia & New Zealand Travel (ANZ Group)",
"IACOUNTRY":"Argentina",
"IAPRINCIPALAGENT":"",
"IAADDRESS2":"",
"IAAGENCY":"Australia & New Zealand Group (ANZ Group)",
"IAEMAIL":"info#anzgroup.com.ar",
"IAPHONE":"+54 11 4311 9828",
"IAWEBSITE":"http:\/\/www.anzgroup.com.ar\/education-105",
"IACITY":"Buenos Aires",
"IALOCATIONHEAD":"Cecilia Minzio"
},
{
"IAAGENCY":"CW International Education",
"IAADDRESS1":"Juan Francisco Segui 3967",
"IAPRINCIPALAGENT":"",
"IALOCATIONHEAD":"Carola Wober",
"IACOUNTRY":"Argentina",
"IACITY":"Buenos Aires",
"IAPHONE":5.41148010867E11,
"IAADDRESS2":"Piso 6A",
"IAWEBSITE":"http:\/\/www.cwinternationaleducation.com",
"IASTATE":"Buenos Aires",
"IALEGALNAME":"CW International Education",
"IAEMAIL":"info#cwinternationaleducation.com",
"IAADDRESS3":"Ciduad Autonoma"
}]
As you can see from the data above, some fields can be empty like address2 but some data will always have a value like agency name or country or website.
so How can I omit a whole "line" when a field is empty? something like:
<h3>{{IAAGENCY}}<h3>
{{if IAADDRESS2 is not empty}}<span>{{IAADDRESS2}}</span><br />{{/if}}
<span>{{IACOUNTRY}}</span><br />
<span>{{IAWEBSITE}}</span>
Thanks
Using handlebars you can just check the length of the said json-value:
<h3>{{IAAGENCY}}<h3>
{{#if IAADDRESS2.length}}<span>{{IAADDRESS2}}</span><br>{{/if}}
<span>{{IACOUNTRY}}</span><br />
<span>{{IAWEBSITE}}</span>
If the length is 0, it evaluates to false, thus the line is omitted

Categories