text-import-engine
Version:
a barebones text templating engine for javascript (with tie-fighters)
15 lines • 1.16 kB
Markdown
TIE is a barebones text templating engine. It was originally intended to be used to render server-side html templates; however it can easily be utilised to create templates for any markup, programming, or plain language with the power of dynamic javascript.
To start using TIE in your project simply install with `npm i text-import-engine` and import the module `import Tie from "text-import-engine"`.
TIE as of now has one function `Tie.render(string, object)` it takes two arguments: the first being the string to be modified, and second being an object containing the data TIE should use to modify the aforementioned string. The syntax to show TIE where in the text these modifications should take place is simple `|o| example |o|` where 'example' is a key in the data object.
`<p>hello |o| name |o| nice to see you again</p>`
`const data = {name: 'jordan'}`
`Tie.render('<p>hello |o| name |o| nice to see you again</p>', data)`
returns: `<p>hello jordan nice to see you again</p>`