Skip to content
bjornpost edited this page Aug 18, 2010 · 4 revisions

Feature Request

Please list features you think its important and things that can improves the library

Proposals

More filter and tag support

By Taylor Luk, bjornpost
Some of the django built-in filters/tags are very useful and h2o should support them

Tags

  • firstof
  • for … empty
  • ifchanged

Filters

  • fill in your filter request here

Dynamic filters

By Taylor Luk
I found Filters are very useful, Adding a lot of filters with similar logic can be repetitive, Dynamic filters are a way to register a filter to a particular pattern, thus, making it more dynamic and reusable filters.

Example
implementing a lot of similar url filters like links_to can be as follow, i implemented the whole CRUD url filters in the same filter definition.


H2o::addFiler('links_to_(.*)', 'dynamic_link_to');

function dynamic_link_to($action, $input, $options) {

if (in_array(array(‘show’, ‘edit’, ‘delete’))) { $collection = Inflector::pluralize(strtolower(get_class($input))); $url = “/{$collection}/{$action}/$input→id”; // $url = Routes::for($input, $action); # You may have a awesome router that generates url in you framework } elseif (preg_match(‘/create_(.*)/’, $action, $match)) { $collection = Inflector::pluralize($match1); $url = “/{$collection}/new”; } HtmlFilters::link_to($input, $url, $options);

}


// CRUD them all

{{ 'New post' | links_to_create_page }}

{{ page.title | links_to_show page }}

{{ 'New post' | links_to_edit page }}

{{ 'Delete post' | links_to_delete page }}