Skip to content

Compile doT templates for ready to use in node and client

License

Notifications You must be signed in to change notification settings

fadomire/grunt-dot-compiler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

97 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grunt-dot-compiler Build Status

Compiles doT templates ready for RequireJS

Getting Started

Install this grunt plugin next to your project's grunt.js gruntfile with: npm install grunt-dot-compiler

Then add this line to your project's grunt.js gruntfile:

grunt.loadNpmTasks('grunt-dot-compiler');

Example

given the following config and template

config

  dot: {
    dist: {
      options: {
        variable : 'tmpl',
        root     : __dirname + '/app/profiles'
      },
      src  : ['app/**/*.dot'],
      dest : 'app/public/templates/tmpl.js'
    }
  }

Options

  • variable String Variable to store everything
  • root String Root of the project
  • requirejs Boolean Enable RequireJS
  • node Boolean Enable Node

templates

templates/item.dot

<li>
  <a>{{=it.url}}<a>
</li>

will output the following script file

dist/tmpl.js

if( typeof define !== "function" ) {
  define = require( "amdefine" )( module )
}
define(function() {
  var tmpl=tmpl|| {};
  tmpl['item']=function anonymous(it) {
    var out='<li><a href="'+(it.url)+'"></a></li>';return out;
  }
  return tmpl;
});

Partials

You can load partials with the load command

  {{##def.partial1: load('./partial1.part') #}} // Use relative paths
  {{##def.partial2: load('test/example/partial2.part') #}} // Use options.root
  
  <div>
    {{#def.partial1}}
    {{#def.partial2}}
  </div>

License

Copyright (c) 2012 Tingan Ho Licensed under the MIT license.

About

Compile doT templates for ready to use in node and client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 98.9%
  • Shell 1.1%