Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "template", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"main": [ | ||
@@ -5,0 +5,0 @@ "index.js" |
12
index.js
@@ -16,7 +16,14 @@ /* | ||
var template = module.exports = {}; | ||
// Mix in the methods from underscore string | ||
_.str = require('underscore.string'); | ||
// Defaults passed to 'delim' | ||
// Mixin non-conflict methods to `_` namespace | ||
_.mixin(_.str.exports()); | ||
// Defaults passed to 'delim' lib | ||
var defaults = {body: '', beginning: '', end: '', flags: 'g'}; | ||
var template = module.exports = {}; | ||
// Process templates | ||
@@ -34,2 +41,3 @@ var template = function(text, data, options) { | ||
settings = _.extend(settings, delim(opts.delims, opts)); | ||
// Inspired by grunt.template | ||
while (text.indexOf(opts.delims[0]) >= 0) { | ||
@@ -36,0 +44,0 @@ text = _.template(text, data, delim(opts.delims, opts)); |
{ | ||
"name": "template", | ||
"description": "An easy-to-use utility library for processing Lo-dash templates.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jonschlinkert/template", | ||
@@ -28,14 +28,16 @@ "author": { | ||
"dependencies": { | ||
"delims": "~0.1.0", | ||
"fs-utils": "~0.1.11", | ||
"lodash": "~2.4.1", | ||
"delims": "~0.1.0", | ||
"fs-utils": "~0.1.11" | ||
"underscore.string": "~2.3.3" | ||
}, | ||
"devDependencies": { | ||
"mocha": "~1.17.0", | ||
"chai": "~1.8.1" | ||
"chai": "~1.8.1", | ||
"mocha": "~1.17.0" | ||
}, | ||
"keywords": [ | ||
"lodash", | ||
"template", | ||
"templates" | ||
] | ||
} |
@@ -95,3 +95,2 @@ # template [![NPM version](https://badge.fury.io/js/template.png)](http://badge.fury.io/js/template) | ||
## Authors | ||
@@ -98,0 +97,0 @@ **Jon Schlinkert** |
@@ -26,18 +26,27 @@ /* | ||
describe('process templates using _.template:', function () { | ||
it('should process a template with default delimiters.', function () { | ||
var compiled = _.template('hello <%= name %>'); | ||
compiled({ 'name': 'fred' }); | ||
var actual = compiled({ 'name': 'fred' }); | ||
expect(actual).to.eql('hello fred'); | ||
describe('Mixin methods from underscore.string:', function () { | ||
it('should slugify the string with _.str namespace', function () { | ||
var tmpl = fixture('_str-slugify.tmpl'); | ||
var actual = template(tmpl); | ||
expect(actual).to.eql('this-should-be-slugified'); | ||
}); | ||
it('should process a template with es6 delimiters.', function () { | ||
var compiled = _.template('hello ${ name }'); | ||
compiled({ 'name': 'fred' }); | ||
it('should slugify the string.', function () { | ||
var tmpl = fixture('_slugify.tmpl'); | ||
var actual = template(tmpl); | ||
expect(actual).to.eql('this-should-be-slugified'); | ||
}); | ||
var actual = compiled({ 'name': 'fred' }); | ||
expect(actual).to.eql('hello fred'); | ||
it('should titleize the string with _.str namespace', function () { | ||
var tmpl = fixture('_str-titleize.tmpl'); | ||
var actual = template(tmpl); | ||
expect(actual).to.eql('This Should Be Titleized'); | ||
}); | ||
it('should titleize the string.', function () { | ||
var tmpl = fixture('_titleize.tmpl'); | ||
var actual = template(tmpl); | ||
expect(actual).to.eql('This Should Be Titleized'); | ||
}); | ||
}); | ||
@@ -185,8 +194,27 @@ | ||
var dest = 'test/actual/COPY.md'; | ||
template.copy(src, dest, {data: data, delims: ['{%', '%}']}); | ||
template.copy(src, dest, data, {delims: ['{%', '%}']}); | ||
var expected = file.readFileSync('test/actual/COPY.md'); | ||
expect(expected).to.eql('Jon'); | ||
file.delete('test/actual'); | ||
file.delete('test/actual/COPY.md'); | ||
}); | ||
}); | ||
}); | ||
describe('process templates using _.template:', function () { | ||
it('should process a template with default delimiters.', function () { | ||
var compiled = _.template('hello <%= name %>'); | ||
compiled({ 'name': 'fred' }); | ||
var actual = compiled({ 'name': 'fred' }); | ||
expect(actual).to.eql('hello fred'); | ||
}); | ||
it('should process a template with es6 delimiters.', function () { | ||
var compiled = _.template('hello ${ name }'); | ||
compiled({ 'name': 'fred' }); | ||
var actual = compiled({ 'name': 'fred' }); | ||
expect(actual).to.eql('hello fred'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14170
27
246
4
109
+ Addedunderscore.string@~2.3.3
+ Addedunderscore.string@2.3.3(transitive)