-
Notifications
You must be signed in to change notification settings - Fork 331
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
Move view logic out of templates #56
Comments
Sounds good. I guess the view plugin's render method would have the same parameters as the render method on the content plugin currently? Having to encode data processing logic like date ordering in templates has been the only negative I've had using Wintersmith (otherwise it's been brilliant, great work!). |
Yeah, the processed content would be exposed to the templates by the view, the default view plugin could just be something like: pageView = (plugin, locals, contents, templates, callback) ->
template = templates[plugin.template]
locals.page = plugin
locals.contents = contents
template.render locals, callback |
Would this allow a view plugin to be written to expose processed data in the content tree? If a template could access "pre-processed" data in the content tree, like in Jekyll, it would simplify template logic and lower the barrier for getting started with Wintersmith. Would it be possible to develop a paginator with a pageView? Or would this need a different effort? |
Boom |
There needs to be a better way to process the content tree before rendering it. Currently it has to be done in templates. This works well with templating languages like jade that support inline javascript, but for something like mustache you can only create very simple sites without creating a custom plugin.
I propose to introduce a new plugin type, a view plugin. The view takes over the responsibility of rendering from the content plugin. It will basically be the ContentPlugin's current
render
method.Quick outline of the new structure:
loads and preprocesses content
provides a 'view' property to tell ws what view to pass it to
called with a content plugin instance to render
should call back with a read stream and a filename to write to
helper plugin passed to the view plugin when rendering
A helper will load all js/coffeescript files in
./views
as view plugins but you should also be able to register global view plugins.And to provide backwards compatibility a default "template" view is available that just renders with the template defined by the content.
It would be great to get some input from you awesome people writing plugins for wintersmith: @smebberson @joefiorini @sfrdmn @mnmly @imothee @jnwng @lhagan @ajpiano @stephenallred @vitch (i hope i didn't miss anyone :)
The text was updated successfully, but these errors were encountered: