Skip to content

Commit

Permalink
Added layout(path) helper to change the layout within a view. Closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Apr 2, 2011
1 parent 25bddf3 commit 371d66b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/layout-control/views/pages/alternate.ejs
@@ -1,2 +1,2 @@
<% locals.layout = 'layouts/alternate' %>
<% layout('layouts/alternate') %>
<h1>Page</h1>
5 changes: 5 additions & 0 deletions lib/view.js
Expand Up @@ -346,6 +346,11 @@ res._render = function(view, opts, fn, parent, sub){
if (cacheViews) cache[orig.view] = view;
}

// layout helper
options.layout = function(path){
layout = path;
};

// render
var str = view.fn.call(options.scope, options);

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/layout-switch.jade
@@ -1,2 +1,2 @@
- locals.layout = 'layouts/alternate'
- layout('layouts/alternate')
h1 My Page
2 changes: 1 addition & 1 deletion test/fixtures/layouts/alternate.jade
@@ -1 +1 @@
#alternate= body
#alternate!= body

0 comments on commit 371d66b

Please sign in to comment.