[ckan-dev] RFC snippets

Toby Dacre toby.okfn at gmail.com
Fri Apr 13 12:50:16 UTC 2012


On 13 April 2012 13:45, Sean Hammond <sean.hammond at okfn.org> wrote:

> Btw, do we need both templates/_snippet and templates/snippets?
>
>
I think not _snippet just has one piece of api-help at the moment I'll see
the best way of cleaning it out with minimal disruption
I think the real one should be called snippets as it is overridable for
extensions etc and _ suggests it's private


> On Thu, Apr 12, 2012 at 12:05:19PM +0100, Toby Dacre wrote:
> > Hi,
> >
> > As work on cleaning our templates and aiding reuse/avoiding duplication
> > I've prototyped some snippet functionality.
> >
> > The idea is to have a folder of snippets in templates that can then be
> > rendered  as needed via a helper function.  This helps reduce the
> > size/complexity of _util.html etc.  It allows individual page components
> to
> > be easily customised by extensions without duplicating content which
> > remains identical.
> >
> > example:
> >
> > ${h.snippet('package_list', packages=packages)}
> >
> > This renders the template "snippets/package_list.html" passing
> {'packages'
> > : packages} and inserts it into the page.
> >
> > Multiple keywords can be passed as needed which allows us to easily
> create
> > snippets from our existing xhtml
> > Any Genshi filters are applied to the rendered html
> >
> > Issues:
> > Should we be more explicit in passing the full template name?
> > Currently render() is partly reimplemented in snippet() - only about 10
> > lines of code for the whole function - is this a bad idea and all
> rendering
> > should go through a single renderer?
> > Can anyone think of why snippets are a bad idea?
> > Any other thoughts?
> >
> > Toby
> >
> > PS I've also made a convert_to_dict() helper function so that we can
> remove
> > further duplication in _util.html eg package_list() and
> > package_list_from_dict() which seems to work happily (at least for those
> > particular functions).
>
> > _______________________________________________
> > ckan-dev mailing list
> > ckan-dev at lists.okfn.org
> > http://lists.okfn.org/mailman/listinfo/ckan-dev
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> http://lists.okfn.org/mailman/listinfo/ckan-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20120413/557d48dd/attachment-0001.html>


More information about the ckan-dev mailing list