Hi monks!
I'm new to Mojolicious and I've got the following question.
I'd like to have a drop-down menu which would be generated from a list of directories in a specific directories. Here's a helper for getting this list:
helper thumbs => sub {
my @thumbs;
my $dir = 'public/images/thumbs';
my $dh;
opendir $dh, $dir;
foreach (readdir $dh) {
next if /^\.$|^\.\.$/; #let's assume there are no files in thi
+s dir, only dirs.
push @thumbs, $_;
}
closedir $dh;
return @thumbs;
};
I also have a main.html.ep which is a layout for all the other "pages". Here it is:
<html>
<head>
<link rel="stylesheet" href="../main.css">
<body>
%= include 'header'
<div id="main_div">
<div id="menu">
<ul>
<li>link1</li>
<li>link2</li>
<li>link3</li>
</ul>
</div>
<div id="r_menu">
<div class="inner_block_1">
some block
</div>
<div id="content">
<%= content %>
</div>
</div>
<div id="footer">
<p>
Footer info.
</p>
</div>
</body>
</html>
As you can see, this layout includes "header.html.ep" template, and it is where drop-down menu is generated.
The quesion is: how do I pass the arrayref of @thumbs array to the header.html.ep template? This header.html.ep is stored in "templates" directory and it is not even mentioned in mainapp.pl!
In case you need it, I provide the code for header.html.ep, but it is not very important in this case:
<div id="header">
<div id="top_menu">
<ul id="menul">
<li><a href="/index">Root</a></li>
<li><a href="/quotes">Quotes</a></li>
<li id="sub1">Pics
<ul>
<% some perl code to generate <li> tags
<li><a href="vu">pic</a></li>
</ul>
</li>
<li><a href = "/logout">Выйти</a></l
+i>
</ul>
</div>
</div>
Thank you in advance!