I have this line in my jade file where i want to set the value #{target} but I get an error when it renders that this is illegal
input(type='hidden' name='target' value=#{target})
I believe this should be:
// note the double qoutes around `#{}`
input(type="hidden" name="target" value="#{target}")
Remove #{}. It should be value=target.
I just tried this and you couldn't use interpolation, it worked like this for me:
input(type="hidden" name="upload" id="upload" value=upload._id)
Related
I'm trying to get the following code as inline notation:
<f:if condition="{newsItem.tags}">
<f:for each="{newsItem.tags}" as="tag">
{tag.title}
</f:for>
</f:if>
I've managed to get the if statement like this:
{f:if(condition: newsItem.tags, then: ',')}
That works perfectly, now I only need to put the for loop inside the "then: ' ' " part.
I tried that, but it gets messy and always ouputs a text not with the listed tags as intended.
I appreciate all the help.
This should work
{f:if(condition: newsItem.tags, then: '{tag.title -> f:for(each: newsItem.tags, as: "tag")}')}
I normally use http://www.fluid-converter.com/ to help in those cases. It does not support complex example, but if you use it viewhelper for viewhelper it certainly helps.
I have an HTML file which contains the below code snippet.
<div class="col-sm-2 col-sm-offset-1">
<div class="countBox success" id="success">
<h2>467</h2>
Passed Tests
<span class="glyphicon glyphicon-eye-open"></span>
</div>
</div>
I have a regular expression (.*)</h2>\r\nPassed to get the value 467. It is worked till yesterday. But, it is not working now. I have tried by replacing single slash by double slash to new line and row. Used "\s+" to cover whitespace. All failed in error. Could anyone please guide me on how to get the value as 467 by using regular expression for the above code snippet?
It is better to catch <h2>(\d+)</h2> to ensure only a h2 header with a number inside. By the way, \r\n is only one convention (in windows) to represent end of line, but in unix it is only \n so to be more platform independent, you can do \r?\n (marking the \r as optional) and you have to get on the whitespace in front of Passed., so a good (but not probably the best) regexp would be:
<h2>(\d+)<\/h2>\r?\n\s*Passed
See demo.
A seemingly straightforward question I cannot seem to crack. I am retrieving escaped & sanitized html from a database and I want to unescape it and render it as html in Jade. I have seen this jade html escaped string question, but the answer is NOT what I want. In the answer to this question the tag is rendered as a string, and NOT as markup. I specifically want the escaped string to be rendered as markup. I have tried the following with the following results.
var escapedstring = '<p>Some Textlt;/p>';
In Jade...
1. div=escapedstring renders <div><p>Some Text</p></div>
2. div!=escapedstring renders <div><p>Some Text</p></div>
3.div
!{escapedstring} renders <div><p>Some Text</p></div>
4.div
#{escapedstring} renders <div><<p>Some Text</p>><!--<p>Head Lease</p>--></div>
Using unescape(escapedstring) produces the same results. Can someone show me what I am doing wrong please?
TIA
For anyone else who comes here, this is what I did. Many thanks to stdob who commented. I have a module called viewhelpers which I add to the locals object globally as a property called vh so that it is available to the jade views. I then npm install a module called html-entities (https://www.npmjs.com/package/html-entities). Then in my viewhelpers I added these two lines..
var ent = require('html-entities').XmlEntities;
module.exports.decode = ent.decode;
Then in my view I can simply use
div!= vh.decode(tenancynote.note)
Hope this helps someone.
I have an ejs file in my sails application that looks like this
<a href='/<%= viewname %>?where={"name":"<%= profile.pname %>"}'>
This works for most of the names with the exception of one that has an apostrophe in it. Essentially EJS parses the apostrophe as a sing quote which closes the href and makes the name I'm passing incorrect
http://localhost:1337/myviewnamwe?where={"name":"tom
where it should be
http://localhost:1337/myviewnamwe?where={"name":"tom's diner}
I would use URL encoding for the critical part: {"name":"<%= profile.pname %>"}
More info:
http://www.ruby-doc.org/stdlib-1.9.3/libdoc/uri/rdoc/URI/Escape.html
http://www.w3schools.com/tags/ref_urlencode.asp
I want to write a string with quotes in a jsp page which is using jstl tag c:out for its value that means I want to write:
c:out value = '"4"'
Please suggest asap..
Did you try to use escapeXml attribute?
<c:out value='"4"' escapeXml="false"></c:out>
Try this.
<c:out value='\\"4\\"'/>