Comments (10)
this happens on other occasions too!
<a href="/classifieds/favorite.html?id=${id}" class="favstar tipsyn" rel="${id}" title="Dodaj med priljubljene"></a>
outputs
<a title="Dodaj med priljubljene" rel="518" class="favstar tipsyn" href="/classifieds/favorite.html?id=$%7Bid%7D"></a>
from jsrender.
${foo} should HTML encode, but not URL encode.
Use {{html foo}} if you don't want any encoding. If you want it to url encode you should write your own URL encoding function, and use {{html myNamespace.myUrlEncode(foo)}}.
That said, I don't know what you are doing to end up with encoding of {{if as %7B%7Bif. It looks like you are encoding your template before using it.
from jsrender.
but in my case the {{ doesn't get processed.... maybe cause I am fetching the html from json response
from jsrender.
Yes, you should check the correctness of the template, and ensure it did not get encoded by your 'ajax pipeline'.
from jsrender.
strange thing is, that it is working well with jquery's (yours) tmpl...
if I replace
tpl = $(tpl).render(AD);
with
tpl = $.tmpl(tpl, AD).html();
works perfectly
the problem is...that is 2/3 slower! instead of ~70ms i get ~170ms
from jsrender.
lol, thees git buttons... confusing at times [:D]
now:
I checked the HTML string I get from ajax response and it is OK...I even tried unescape it...
here is my tpl string
<span> <li id="c_${id}" class="tiles ${sponsored} ${region} ${area_id} ${mine}"> <div class="ad_wrapper"> <div class="mine corner_sticker"></div> <div class="chk_classified_box ccol"> <input class="optmenu_chk" type="checkbox" name="chk_classified" value="${id}" /> <a href="/classifieds/favorite.html?id=${id}" class="favstar tipsyn" rel="${id}" title="Dodaj med priljubljene"></a> {{if mine !== ''}}<a href="/oglas/${slug}.html?edit=true" class="edit_ad tipsyn" rel="${id}" title="Popravi oglas"></a>{{/if}} </div> <div class="photo_box ccol"><a href="/oglas/${slug}.html" title="${title}" rel="${slug}" class="appad"><img src="{{if photo}}html ${photo}{{else}}/media/no_photo.png{{/if}}" class="photo" alt="${slashes_title}" /></a></div> <div class="data ccol"> <p class="carea">${area}</p><span class="small when" title="Oddano: ${created}">${tpl_days_ago()}</span> <h3><a href="/oglas/${slug}.html" class="title appad" title="${title}" rel="${slug}">${title}</a></h3> <p><span class="summary gray">${summary}</span></p> <div class="usr_data"> <a href="/oglasi/uporabnik/${OWNER.id}.html" class="tipsyn appclassifieds" title="Prikaži vse oglase uporabnika" >${OWNER.name}</a><br /> <span class="small">${OWNER.address} - ${OWNER.postal} ${OWNER.city} <small class="distance">(<a title="Zračna razdalja" class="set_location distance tipsyn">${tpl_distance()}</a>)</small></span> </div> <span class="cviews"><i>Število prikazov: </i><b class="tipdata">${views}</b></span> </div> <dl class="ccol"> <dt>Področje</dt><dd>${area}</dd> <dt>Prodajalec</dt><dd>${OWNER.name}</dd> <dt>Lokacija</dt><dd><span title="<small>Zračna razdalja:</small> <b class='distance'>${tpl_distance()}</b>" class="tipsyn">${OWNER.city}</span></dd> <dt>Cena</dt><dd><b>${f_price}</b></b></dd> </dl> <div class="price_box ccol"><h4>${f_price}</h4></div> <div class="clear"></div> </div> </li> </span>
from jsrender.
I don't understand why you are doing tpl =
So I will close this issue. JsRender does not encode { or }. If you sure that you are seeing a bug in JsRender and not in your app, you would need first to create a very simple test case in JsFiddle, showing how JsRender incorrectly encodes url slashes; - showing that the encoding error is happening within JsRender.
from jsrender.
you might be right that the problem is on my part... but how is that (in my case) tmpl is working OK and render is not?
I tried to make a testcase that behaves the same way as my app, but it works on js fiddle
and just to give you context more accuarate version
from jsrender.
a) don't load jquery.render.js and jquery.tmpl.js on the same page. They are not designed to be used together in a page. For a given page, choose one or the other.
b) To load a template from a string, first compile as a named template, then render the compiled template using
$.template( "myTemplate", templateString )
var rendered = $.render( "myTemplate", myData );
See the docs here: http://api.jquery.com/category/plugins/templates/ - in particular
http://api.jquery.com/jquery.tmpl/
http://api.jquery.com/jquery.template
JsRender uses the same design except tmpl() is renamed to render().
from jsrender.
Great! thank you! You are the man!
precompiling did herlp a lot! instead of 70ms I get now <20ms! Plus the photos work too ;)
Thanks again!
from jsrender.
Related Issues (20)
- template content in external files HOT 2
- renderFile to accept a file as input HOT 2
- Nested props loop is not picking up properties of a function HOT 4
- any breaking changes between 0.9.82 and current 1.0.5 ? HOT 2
- JSRender strips multiple white spaces from input HOT 3
- Node + jsRender: allow absolute paths, (and also passing context to renderFile) HOT 8
- space is not html-encoded HOT 6
- regex not working HOT 2
- Difference between Browser and Node app - Null Propagation Operator HOT 2
- Conditional check if equal to string HOT 5
- Incomplete jsrender.min.map file HOT 2
- Provide support for passing an ID selector to $.templates() even when using JsRender without jQuery HOT 6
- Please provide a good documentation on how to use this in Angular 8+ or React 9+ versions HOT 2
- {{if}} tag doesn't work on keys with array or object with properties HOT 1
- swig.renderFile gives callback function required error HOT 3
- Chrome Extension Manifest V3 HOT 3
- $(...).render is not a function HOT 1
- How can I load data from jsrender template and update it HOT 2
- Using a tmpl selector that begins with a # but is not an ID selector does not work HOT 1
- Get an error t is not a function when adding if block HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jsrender.