mikemaccana / dynamic-template Goto Github PK
View Code? Open in Web Editor NEWSimple dynamic ES6 templates
Simple dynamic ES6 templates
Tried rendering an array using this template....
<ul>
${this._items.map((item) => `
<li>${item}</li>
`.trim()).join('')}
</ul>
but this module's function renders it as:
<ul>
${this._items.map((item) => `
<li>${item}</li>
`.trim()).join('')}
</ul>
is there another technique to get this module to render an array?
an can lead to XSS vulnerabilities. This is an example how this can happen:
https://jsfiddle.net/Lamik/w97qdpvf/
So you should point this out in your module description.
It is more a feature request, but ES6 string templates can interpolate the nested properties of an object:
describe('String interpolation', () => {
it("Allow top level fields ", async () => {
const res = fillTemplate("A: ${a}, B: ${b}", { a: 100, b: "xxx" })
expect(res).eq("A: 100, B: xxx")
})
it("Allow object fields ES6 dynamic", async () => {
const res = fillTemplate("A: ${model.a}, B: ${model.b}", { model: { a: 100, b: "xxx" } })
expect(res).eq("A: 100, B: xxx")
})
it("Allow object fields ES6", async () => {
const obj = { model: { a: 100, b: "xxx" } }
const res = `A: ${obj.model.a}, B: ${obj.model.b}`
expect(res).eq("A: 100, B: xxx")
})
})
This package implements it, but the syntax is questioning: https://www.npmjs.com/package/string-interpolation
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.