I'd like to propose to change {<
I'd like to propose to change {< to something else that does not use < Any other character that is not required to be encoded by html is fine, i.e {%
Even if dust is not changing {<, it will be nice to support {% as alternative way to indicate a start of a partial.
The reason is because < is encoded by most code in any layer. I realized people will say, I could have placed my template inside script block so that they are not encoded.
However, if dust can avoid using {<, then I don't need script block at all, thus making dust even more clean and powerful!!!
Say I basically want all my template inside a div, i.e:
<div id="template1">
everything works {name}
dust, is excellent
except when I want to use {>"partial"} here it will stop working
</div>
<div id="partial">
</div>
Example of my code that will load and compile the div's above, the code must replace the escaped {> by jQuery's .html(). I could've written a text parser, but I don't want to do that.
function ( html ) {
var $div = $( '<div></div>' );
$div.append( html );
_.each( $div.find( '> div' ), function compile ( template_dom ) {
// stupid dust shouldn't have used {> to start a partial
// now we have to hack a {> which is escaped by html
console.log($( template_dom ).html().replace(/{>/g,'{>'));
var html = $( template_dom ).html().replace(/{>/g,'{>'),
compiled = dust.compile( html,
template_dom.id );
dust.loadSource( compiled );
} );
} );
thanks @mpermana. We will analyze this issue.
@jimmyhchan @vybs @smfoote @rragan guys what do you think. I think that @mpermana found a nice issue to discuss.
It would certainly be doable to provide an alternate syntax (except for the dwindling supply of special characters). Wouldn't we need an alternate for inline partials too? {<xxxx} would seem problematic.
The current notation is widely used in other mustache/handlebars/derivative environments so folks coming to dust from there find it familiar. I've never run into this issue but I can see how it would be troublesome if you are stashing templates in the HTML. Since we largely precompile all our templates they don't end up residing in the DOM.
I think the concern is valid but at this stage the changes seem unrealistic. Closing for now since this has been idle.