Closed phil-lavin closed 12 years ago
Can't you just put that into a normal .php view?
For now I have done that in the form of an include - so filters.php includes filters.mustache and that is passed to the main view in an unparsed form. It seems more elegant to be able to get the unparsed template from the parser package's View class.
E.g.
Controller ...
<?php
// Get filters view of first subcategory
$this->template->content->filters = \View::forge('filters.mustache', static::get_response_data(reset($subcats)->id));
// Pass unparsed filter template to view
// @TODO - unhack this - see views/filters.php
$this->template->content->filters_markup = \View::forge('filters');
filters.php...
<?php
include('filters.mustache');
As we made extensions meaningfull for parsing they should remain meaningfull, anything else creates unnecessary ambiguity.
What is your suggested solution to this problem?
I don't consider this a problem. The View class and the Parser package extended View class isn't meant to serve up unmodified templates, if you want that you need to just use File::read()
or write a wrapper class yourself for serving these up.
JS libraries, such as handlebars, require the raw/unparsed template including in a <script></script> tag in order to use AJAX. The basic design pattern would be that a view.mustache would be created and data would be applied to it and it would be rendered parsed. You would then render it unparsed, wrapped in a script tag, and handlebars would handle the ajax request for JSON and the client side parsing of this.