Skip to content

letsgetrandy/NUTS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Codacy Badge Code Climate bitHound Score

NUTS

Nearly Useless Template System

NUTS is a nearly useless templating system for Javascript.

Why use it?

Having functionality in your template system creates more possible points of failure, making it harder to test and harder to find bugs when they exist. It's better if your functionality is inserted and removed from some other, testable member, while your templates hang around behind the scene just spitting out the end result.

How to use it

NUTS is simple to use.

First, create a template:

var template = '<div>[:text]</div>';

Then, render it, by passing an object of values:

var obj = {
    text: "Hello world!"
};
var html = nuts(template, obj);

Your context object can also contain functions...

var userTemplate = '<div>Full name is: [:name]</div>',
    userModel = {
        "firstName": "Fred",
        "lastName": "Flintstone",
        "name": function() {
            return this.firstName + ' ' + this.lastName;
        }
    },
    html = nuts(userTemplate, userModel);;

That's it!

About

Nearly Useless Template System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published