UNPKG

tastypie

Version:

Tastypie is a webservice API framework for Node.js based on Django's Tastypie Framework. It provides a convenient, yet powerful and highly customizable, abstraction for creating REST-style interfaces

20 lines (14 loc) 496 B
var toString = require('../lang/toString'); var get = require('../object/get'); var stache = /\{\{([^\}]+)\}\}/g; //mustache-like /** * String interpolation */ function interpolate(template, replacements, syntax){ template = toString(template); var replaceFn = function(match, prop){ return toString( get(replacements, prop) ); }; return template.replace(syntax || stache, replaceFn); } module.exports = interpolate;