longsword
v0.1.1
Published
Simplifying partial page updates in vanilla JavaScript web applications
Downloads
4
Readme
Longsword.js
About
The goal is to simplify partial page updates in projects where using a full front-end framework/library is overkill.
Right now there's not a lot of features and a lot of limitations, but I plan on updating when I can.
Limitations
- There's no feature for looping (yet)
- You must use flat objects (i.e. just a single value. no nested objects, no arrays, etc.)
These will be addressed shortly.
Installation
npm install longsword
Usage
Pretty simple right now:
- Create template in the form of a HMTL file
- Call longsword with three arguments: path to template, an object representing your data, and id of the element where the compiled template will be inserted.
Template syntax is pretty simple:
<h1> Hello! My name is {name}</h1>
Template parser will expect the word between the braces to be a key in the data object you pass.
Example:
import longsword from 'longsword';
const data = {
// data
}
longsword("path/to/template", data, "elementId");