Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A template library for text files.
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
README.md
index.js
package.json

README.md

Textlates

Textlates is a simple template library for text files in Node.JS

Usage

Create your basic text file with the formatting you want, and wrap variables you would like to insert in the familiar string interoplation syntax #{}

Hello #{name}

#{greeting}

What would you like to eat for #{meal} today?

Require in textlates and then pass it the files location, the data for the variables you would like inserted, and a normal callback.

var textlates = require('textlates')
  , file = __dirname + '/file.txt'
  ;

var data = {
    name: 'taterbase'
  , greeting: 'How are you today?'
  , meal: 'breakfast'
};

textlates.render(file, data, function(err, result){
  if(err)
    return console.log(err);

  console.log(result);

  /*

  Hello taterbase

  How are you today?

  What would you like to eat for breakfast today?

  */
});

License

MIT

Something went wrong with that request. Please try again.