2017 © Pedro Peláez
 

library do-t

Concise and fast javascript templating compatible with nodejs and other javascript environments

image

pdir/do-t

Concise and fast javascript templating compatible with nodejs and other javascript environments

  • Tuesday, August 1, 2017
  • by MDevster
  • Repository
  • 0 Watchers
  • 0 Stars
  • 65 Installations
  • JavaScript
  • 1 Dependents
  • 0 Suggesters
  • 878 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

doT

Created in search of the fastest and concise JavaScript templating function with emphasis on performance under V8 and nodejs. It shows great performance for both nodejs and browsers., (*1)

doT.js is fast, small and has no dependencies., (*2)

Build Status npm version Coverage Status, (*3)

Features

custom delimiters
runtime evaluation
runtime interpolation
compile-time evaluation
partials support
conditionals support
array iterators
encoding
control whitespace - strip or preserve
streaming friendly
use it as logic-less or with logic, it is up to you

Docs, live playground and samples

http://olado.github.com/doT (todo: update docs with new features added in version 1.0.0), (*4)

New in version 1.0.0

Added parameters support in partials

{{##def.macro:param:


{{=param.foo}}
#}} {{#def.macro:myvariable}}

Node module now supports auto-compilation of dot templates from specified path

var dots = require("dot").process({ path: "./views"});

This will compile .def, .dot, .jst files found under the specified path. Details * It ignores sub-directories. * Template files can have multiple extensions at the same time. * Files with .def extension can be included in other files via {{#def.name}} * Files with .dot extension are compiled into functions with the same name and can be accessed as renderer.filename * Files with .jst extension are compiled into .js files. Produced .js file can be loaded as a commonJS, AMD module, or just installed into a global variable (default is set to window.render) * All inline defines defined in the .jst file are compiled into separate functions and are available via _render.filename.definename, (*5)

Basic usage: js var dots = require("dot").process({path: "./views"}); dots.mytemplate({foo:"hello world"}); The above snippet will: * Compile all templates in views folder (.dot, .def, .jst) * Place .js files compiled from .jst templates into the same folder These files can be used with require, i.e. require("./views/mytemplate") * Return an object with functions compiled from .dot templates as its properties * Render mytemplate template, (*6)

CLI tool to compile dot templates into js files

./bin/dot-packer -s examples/views -d out/views

Example for express

Many people are using doT with express. I added an example of the best way of doing it examples/express:

doT with express, (*7)

Notes

doU.js is here only so that legacy external tests do not break. Use doT.js.
doT.js with doT.templateSettings.append=false provides the same performance as doU.js.

Author

Laura Doktorova @olado, (*8)

License

doT is licensed under the MIT License. (See LICENSE-DOT), (*9)

logo by Kevin Kirchner , (*10)

Thank you @KevinKirchner for the logo., (*11)

The Versions

01/08 2017

dev-master

9999999-dev http://pavelk2.github.io/social-feed-example/

Concise and fast javascript templating compatible with nodejs and other javascript environments

  Sources   Download

MIT

templating template simple fast

01/08 2017

1.1.2

1.1.2.0 http://pavelk2.github.io/social-feed-example/

Concise and fast javascript templating compatible with nodejs and other javascript environments

  Sources   Download

MIT

templating template simple fast