[Catalyst] View Helpers?
Kevin Monceaux
Kevin at RawFedDogs.net
Fri Feb 15 00:08:59 GMT 2013
On Thu, Feb 14, 2013 at 12:10:44PM -0600, Kevin Monceaux wrote:
> It looks like someone already wrote a Rails like LinkTo plugin:
>
> http://search.cpan.org/~hirafoo/Template-Plugin-LinkTo-0.093
>
> For my personal projects I'd probably create something similar that takes
> parameters similar to uri_for_action, something like:
>
> [% LinkTo('Recipes', 'recipe/list') %]
After a little tinkering, and reading old posts on template plugins, maybe a
template plugin is the wrong approach. For the above to work it would need
access to Catalyst uri functions. In one old post, T0m says:
You don't want to do this.
TT plugins should be for trivial formatting stuff only, teaching them
about your application context is massively breaking abstraction.
So, would the LinkTo function I described be better implemented as:
[% c.LinkTo('Recipes', 'recipe/list') %]
If so, how does one make a function available in views via the CATALYST_VAR,
and where is the best place for such a function's code in a Catalyst
project?
--
Kevin
http://www.RawFedDogs.net
http://Lassie.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX
What's the definition of a legacy system? One that works!
Errare humanum est, ignoscere caninum.
More information about the Catalyst
mailing list