in reply to Passing a value to Mojo::Template template

The data for the variables should be in a single hash. $mt->render_file('myfile.html.ep', { data => $data, test => $code } ) works for me.

Replies are listed 'Best First'.
Re^2: Passing a value to Mojo::Template template
by Anonymous Monk on Apr 14, 2021 at 17:07 UTC
    Thats great and made me think about another possibility, if I had multiple values as:
    { data => $data, test => $code, color => 'blue', name => $names, ... }

    Could I combine all of it into one variable and than pass to "$mt->render_file()"?

    Thank you!
      Could I combine all of it into one variable and than pass to "$mt->render_file()"?

      I'm not sure I fully understand the question... do you mean something like the following (which works too)? If not, please provide more context, preferably in the form of an SSCCE (see also How do I post a question effectively?).

      my %vars = ( data => $data, test => $code, color => 'blue' ); print $mt->render_file( 'myfile.html.ep', \%vars );
        Sorry for the short code sample there, but you did answer it, thank you. The only downside of it, is that it will add more complexity to extract the data to the template file, right?