Browser does not respect template markup
See original GitHub issueSee https://jsfiddle.net/8vfesbgf/1/
<div id="alltemplates" class="hidden">
<code id="tpl_fieldtype">
<div class="form-group">
<label>{{:fieldname}}</label>
<select class="fieldtype form-control" data-name="{{:fieldname}}">
{{for allfieldtypes}}
<option value="{{:ftype}}" {{ if ftype == fieldtype }}selected{{/if}}>{{:ftype}}</option>
{{/for}}
</select>
</div>
</code>
</div>
See 3 commented blocks in the fiddle - nothing of these returns correct content. It seems browser does not process this block as is. I see it as:
{{for allfieldtypes}}
<option if}}="" }}selected{{="" fieldtype="" ftype="=" if="" {{="" value="{{:ftype}}">{{:ftype}} </option>
{{/for}}
How do I render this template?
Ubuntu 15.10: Firefox 46.0.1 / Chromium 50.0.2661.102
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
I am trying to debug the markup of my email templates. I ...
I created an html template with NO colors specified (font or background), ... suddenly dark mode is not respected and it appears that...
Read more ><pre>: The Preformatted Text element - HTML - MDN Web Docs
The HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered ......
Read more >Why does HTML require that multiple spaces show up as a ...
Spaces are compacted in HTML because there's a distinction between how HTML is formatted and how it should be rendered. Consider a page...
Read more >  and HTML Space Challenges and Tricks | Mailtrap Blog
If you were to use either of the entities directly in the code, the browser would interpret them as HTML and render them...
Read more >Customizing your templates for email notifications
Note: HTML template editing is not enabled by default for trials. ... the way HTML and CSS are rendered in different web browsers...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you are doing this in a browser then your template should be in a script tag. And then you need to call render and insert the resulting string in to the dom.
JSRender does not somehow make the browser dom understand it’s {{tag}} notation. You place the template in script tag so that the browser will ignore it. Then you use javascript to render the template and insert it into the dom where you would like.
<script id='helloworld' type='text/x-jsrender'> <span>{{>hello }}</span> </script>var model = { hello: ‘world’ };
var rendered = $.template(‘#helloworld’).render(model);
$(‘body’).html(rendered);
On May 27, 2016, at 11:55 AM, Alexey Kolyanov notifications@github.com wrote:
the main problem was, that the code block is parsed by the html engine.
try the following: