Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let view be a directory of views. #20

Open
3rd-Eden opened this issue Mar 12, 2015 · 1 comment
Open

Let view be a directory of views. #20

3rd-Eden opened this issue Mar 12, 2015 · 1 comment

Comments

@3rd-Eden
Copy link
Member

In the current design of things it's only possible to specify one single view for a pagelet. This view in combination with an optional error view is then also send to the client. If your client code needs additional templates to upgrade the graceful degraded content it needs to find it's own solutions for this (Or if you're using multiple React components to render a single pagelet these will all require addition processing as they don't have templates). The solution for this is to allow the view to be a directory with template files.

By default we could either use view.ext or index.ext for the main template and have all other templates be made available using the pagelet.template method where the first argument of this method will be the base name of the template and it would return the given template and or call the template method with the supplied data as second argument (which has yet to be decided).

var Pagelet = require('pagelet');

Pagelet.extend({
  view: __dirname, 
  get: function get(next) {
    next(undefined, {
     header: this.template('header', { title: 'foo' }),
     other: 'data'
  });
}).on(module);
@Swaagie
Copy link
Member

Swaagie commented Mar 13, 2015

Sounds like a good plan, I'd go for index.ext just to follow the same analogy as with index.js, Would it be good to specify a third optional argument as extension, cause I could see people mixing .jsx with handlebars or something. Also I think we can default to __dirname in pagelets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants