visionmedia / minstache Goto Github PK
View Code? Open in Web Editor NEWMini mustache compiling to stand-alone functions
Mini mustache compiling to stand-alone functions
this is more a question than an issue. Do you think it would be possible to create a "render" function that would
return a dom element
accept dom nodes as paramaters
E.g it would be awesome to be able to do :
Minstache.compile("<div>{{object}}</div>")({ object: myComponent.render() })
would be nice to have support for unescaped output, maybe {{{comment}}}
or {{!comment}}
Update: {{!...}}
seems like a really easy fix. I can submit a pull request if you think it's a useful feature.
it'd be sweet for this library to support iteration through arrays.
{ contacts :
[
{ name : 'matt' },
{ name : 'john' }
]
}
<ul>
{#contacts}<li>{name}</li>{/contacts}
</ul>
I took a look at the way the lib is structured - it doesn't look trivial to implement. I feel like it's the last feature missing from a lightweight "core" mustache though.
There is a divergence from the mustache
spec for inverted sections with respect to empty arrays. minstache
seems to be handling them as an iterator, not as an inverted section
https://github.com/janl/mustache.js/blob/0.8.2/README.md#inverted-sections
> require('mustache').render('{{^places}}none{{/places}}', {places: []})
'none'
> require('minstache')('{{^places}}none{{/places}}', {places: []})
''
I think we do not need strong array check at function:
function section(obj, prop, negate, thunk) {
var val = obj[prop];
if (Array.isArray(val)) return val.map(thunk).join('');
if ('function' == typeof val) return val.call(obj, thunk(obj));
if (negate) val = !val;
if (val) return thunk(obj);
return '';
}
I explain why. I have array-like object (extended from Array). And minstache do not understand that array-like object have Array as prototype.
I propose to change Array.isArray(val)
to val instanceof Array
.
And when we using Array.isArray(val)
we forgot about IE8.
Thanks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.