Wednesday, 15 July 2015

javascript - EJS templating language internal logic fails somehow -


I'm partially using EJS and I'm just getting a bug that I understand after wasting a few hours

Title_popover: sentence.Nickname, content_tag: '#' + sentence.namename, icon_popover: 'http://placehold.it/64x64'})% & gt; & Lt;% - Partial (see__partypath ('tag_popover'), {title_popover: 'last modified', content_tag: '#' + sentence.sentenceId})%>

Here is the tag_popower partial:

  & lt;% / ** * dynamic title, a standalone tag with content Creates and popover for additional content * * @ Ultimate class_tag css classes ['tag'] * @ ultimate content_tag tag content * @ ultimate icon_ popup icon icon. [No one] * @palm title_popover popup title will be displayed. * / Title_popover = typeof title_popover! = 'Undefined'? Title_popover: '' class_tag = typesof classes_tag! = 'Undefined'? Classes_tag: 'tags' icon_popover = Type icon_popover! = 'Undefined'? Icon_popover: wrong content_tag = type of content_tag = 'undefined'? Content_tag: ''%> & Lt; Li class = "& lt;% = classes_tag%>" Title = "& lt;% = title_popover%>" & Gt; & Lt; A href = "#" & gt; & Lt;% = content_tag% & gt; & Lt; / A & gt; & Lt;% - Partial (see ___ Pattern ('popover_revration_translation'), {icon_popover: icon_popover})%> & Lt; / Li & gt;  

and finally popover_revision_translation partial:

  & lt;% / ** * dynamic title and body with a healthy Makes popover * * @imove icon_tag icon [none] * / icon_popover = icon_popover! = 'Undefined'? Icon_popover: ''%> & Lt;% console.log ('----------------------' + Type icon_popover)%> & Lt;% console.log (icon_popover? True: incorrect)%> & Lt; Div class = "custom-popover-content hiding" role = "see" and gt; & Lt;% if (icon_popover) {%> & Lt; Img src = '& lt;% = icon_popover% & gt; / & Gt; & Lt;%}% & gt; & Lt; Period & gt; The & lt; / Span & gt; & Lt; / Div & gt;  

So basically, I set my tag_popover partially once, once icon_popover and once code_popover . But it shows the icon twice on the first element, but on the other, where I do not want anyone.

So, I have some console.log to help me understand what's happening because I set the icon only Is done, and set to be set to false if set to undefined: icon_popover = typeof icon_popover! = 'Undefined'? Icon_popover: false .

Here are the server logs:

  ------------------- ------- String truth -------------------------- Boolean False  

So basically whether this string < / Code> or false , this is my if statement & lt;% if (icon_popover) {%> And I do not understand why that is why.

I did more tests, like & lt;% if (icon_popover! == incorrect) {%> or & lt;% if (icon_popover === 'http://placehold.it/64x64') {%> And in both cases I get the same result.

So I do not really get it and I think it may be related to some EJs internal issues or caching, but anyway it's really weird that the log looks something which seems logical But it does not ...

There is no dark magic here :)


No comments:

Post a Comment