Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.
/ templojs Public archive

A lightweight module to define templates for JSON data.

Notifications You must be signed in to change notification settings

fmvilas/templojs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

A lightweight module to define templates for JSON data.

Getting Started

Install the module with: npm install templo

var templo = require('templo'),
    tpl = {
        id:         { type: 'string', required: true },
        name:       { type: 'string', required: true },
        avatar_url: { type: 'string', default: null },
        created_at: { type: 'string', read_only: true, default: 'timestamp' }
    };

templo.render(tpl, {
    id: 1,
    name: 'Fran',
    created_at: '2012-03-01'
});

// It will return something like this:

{
    status: 'ok',
    output: {
        id: '1',
        name: 'Fran',
        avatar_url: null,
        created_at: '2014-10-25T21:09:02Z'
    },
    warnings: {
        created_at: {
            message: "Can't modify read only attribute <created_at>."
        }
    }
}

Documentation

Do you like TemploJS? You can contribute and help documenting it.

Examples

Do you like TemploJS? You can contribute and add some examples on how to use it.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2014 Francisco Méndez Vilas
Licensed under the MIT license.

Analytics

About

A lightweight module to define templates for JSON data.

Resources

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published