question on helpers returning data in template

52 views
Skip to first unread message

ty

unread,
Jul 31, 2012, 9:14:43 AM7/31/12
to mojol...@googlegroups.com
should all helpers used in the template just return output for display, or could they return values such as hash reference, where I could then take that
result and pass it to a taghelper like select_field?

something like

% my $cats = categories
%= select_field category => [ map { [ $_ => $cats->{$_} ] } keys %$cats ], id => 'category'

but that does not seem to work

Best regards,

Ty

Gabriel Vieira

unread,
Jul 31, 2012, 10:25:29 AM7/31/12
to mojol...@googlegroups.com
What is the error?
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mojolicious/-/AfBWdbbdiMYJ.
> To post to this group, send email to mojol...@googlegroups.com.
> To unsubscribe from this group, send email to
> mojolicious...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mojolicious?hl=en.



--
Gabriel Vieira

Alexandr Alexeev

unread,
Aug 1, 2012, 2:01:32 AM8/1/12
to mojol...@googlegroups.com
As far as i know, helpers are just functions, that could be easily
called from templates. They could return anything - lists, pointers to
hashes, anonymous functions and so on. The problem is that you can use
only scalars in %= expressions.

2012/7/31 Gabriel Vieira <gabriel...@gmail.com>:
С уважением, Александр
Личный блог: http://eax.me/
Мой форум: http://it-talk.org/
Мой Twitter: http://twitter.com/afiskon
Message has been deleted

ty

unread,
Aug 1, 2012, 7:50:29 AM8/1/12
to mojol...@googlegroups.com
I figured it out, it was a syntax error.  I had some characters that were not properly quotes when I tried to incorporate some jquery code with the select_field helper.  Thanks for everyone's reply.  I appreciated it.

Best regards

Ty
Reply all
Reply to author
Forward
0 new messages