0.1.1 • Published 5 years ago

longsword v0.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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:

  1. Create template in the form of a HMTL file
  2. 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");