Thank you for your suggestion.

When I tried to encapsulate this code in a subroutine, and call it in another subroutine, Dancer2 seems to automatically use the main template located in the layout directory as a wrapper to this snippet, as well at to the entire page that generated an undesired visual effect. Ideally, it should be possible to write a simple subroutine that returns a menu, that, in turn can be invoked in some other subroutine that generates an arbitrary form:
sub dropdown_menu { # should generate only an HTML snippet of a menu #my ..arguments..; return template 'form_menu.tt', { ...argument hash... }; } . . . get '/' => sub { # generates the actual form that is used as [% conten +t %] in the layout/main.tt template template 'some_form.tt', { menu1 => dropdown_menu(...parameters1...), menu2 => dropdown_menu(...parameters2...), radio1 => radio_group(...parameters3...), . . } }
Does that make sense, or am I accidentally breaking some Dancer2 paradigm? I apologize if this question is trivial.

In reply to Re^3: How do you use Template Toolkit with Dancer2? by PiotrS
in thread How do you use Template Toolkit with Dancer2? by v3ritas

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.