pimterry / server-components

:wrench: A simple, lightweight tool for composable HTML rendering in Node.js, based on web components.
https://pimterry.github.io/server-components
MIT License
216 stars 12 forks source link

Make it easy to integrate server components and templating libraries like Mustache for data #14

Open pimterry opened 8 years ago

pimterry commented 8 years ago
pimterry commented 8 years ago

Could create a component that extends server components and adds a <data-placeholder name=""> component? Would only work with inline content, not attributes, which is very limiting indeed.

Attributes are dangerous generally though with Mustache etc; lots of potential to encourage XSS vectors by rendering to unstructured string data and then interpreting that directly (as server components input).

Want a HTML-understanding templating language really, but that doesn't seem to exist (arguably, Server Components is it). Could add one? Allow mustache constructs in the HTML, and interpret them out before component rendering? Feels a bit crazy here, risk of creep, but very useful, and in line with what larger frameworks do (e.g. {{ }} in Angular and Ember). Should this be a manual standalone step (components.template(html, { name: Tim }).render().then...) to keep steps simple, or part of a normal render() call, like everywhere else?

This is a clear strong need for the majority of use cases, needs to have a good out-of-the-box story in Server Components.