Merge branch 'ejs'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by visionmedia · committed by visionmedia · parents 2bcea3a, 8d74136 · Browse files · 7 files·+70 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+70 added−0 removed
- tests:+14 added−0 removed
- other:+56 added−0 removed
Provenance
- Commit
2d132cd- Tree
d21d6d0- Author
visionmedia <tj@vision-media.ca>- Committer
visionmedia <tj@vision-media.ca>- Parent 1
2bcea3a- Parent 2
8d74136
7 files changed+70 added−0 removed
added:examples/hello-world/views/front.html.ejs+2 added
1+<h1><%= title %></h1>2+<p>test</p>added:examples/hello-world/views/layout.html.ejs+8 added
1+<html>2+ <head>3+ <title><%= title %></title>4+ </head>5+ <body>6+ <%= body %>7+ </body>8+</html>added:examples/hello-world/app.js+17 added
1234567891011121314151617
require.paths.unshift('lib')require('express') configure(function(){ set('root', __dirname)})
get('/', function(){ this.render('front.html.ejs', { locals: { title: 'Hello World' } })})
run()No newline at end of fileadded:lib/support/ejs/lib/ejs.js+25 added
12345678910111213141516171819202122232425
/** * Compiled template cache. */
var cache = {}
exports.render = function(str, options) { options = options || {} var fn = cache[str] = cache[str] || new Function("locals", "var p=[],print=function(){p.push.apply(p,arguments);};" + "with(locals){p.push('" + str .replace(/[\r\t\n]/g, " ") .split("<%").join("\t") .replace(/((^|%>)[^\t]*)'/g, "$1\r") .replace(/\t=(.*?)%>/g, "',$1,'") .split("\t").join("');") .split("%>").join("p.push('") .split("\r").join("\\'") + "');}return p.join('');") return fn(options.locals || {})}
modified:lib/express.js+1 added
12345672 unmodified lines
require.paths.unshift(__dirname + '/support/ext/lib')require.paths.unshift(__dirname + '/support/ejs/lib')require.paths.unshift(__dirname + '/support/haml/lib')require.paths.unshift(__dirname + '/support/sass/lib')require.paths.unshift(__dirname + '/support/multipart/lib')require('ext')2 unmodified linesmodified:spec/spec.plugins.view.js+14 added
1 2+ejs = require('ejs')3+4 describe 'Express'5 before_each6 reset()7 end14 unmodified lines22 set('partials').should.eql 'magicland/partials'23 end24 end25 26+ describe 'ejs'27+ it 'should work without options'28+ var str = '<h2><%= "Title" %></h2>'29+ ejs.render(str).should.eql '<h2>Title</h2>'30+ end31+ 32+ it 'should work with locals'33+ var str = '<h2><%= title %></h2>'34+ ejs.render(str, { locals: { title: 'Title' }}).should.eql '<h2>Title</h2>'35+ end36+ end37+ 38 describe '#partial()'39 before_each40 set('views', 'spec/fixtures')41 set('partials', 'spec/fixtures/partials')177 unmodified linesmodified:Makefile+3 added
22 unmodified lines23 24 app-chat:25 @$(NODE) examples/chat/app.js26 27+app-hello-world:28+ @$(NODE) examples/hello-world/app.js29+30 app-upload:31 @$(NODE) examples/upload/app.js32 33 app-coffee-upload: compile-coffee13 unmodified lines