1. Write in app.pl
plugin 'Config'
2. Create app.conf in the app.pl directory locally, and the system will automatically load
3. app.conf parameters are in perl format
{ attr1 =>"value", attr2 =>{name =>"name value", value =>"value value"} }
4. Use when calling
<%= app->plugin('Config')->{attr1} %>
How to write the Model for public use, and how to load
1 in the template. Set a Model, which is actually a perl package
mkdir lib; mkdir MyApp/Model/XXX.pm
2. edit XXX.pm
package MyApp::Model::XXX; sub func1 { xxx; } sub func2{ xxx; } 1;
3. Write like this when calling
use lib 'lib'; use MyApp::Model::XXX; MyApp::Model::XXX->func1();
Call it in the template and write it like this
% use MyApp::Model::XXX; % MyApp::Model::XXX->func1();
Template skills
1. Template can nest template.
For example, if I use the same selector on multiple pages, I can take the html of this selector out as a template
@@ gl_selector.html.ep <label for="gl" class="col-sm-2 control-label">GL</label> <div class="col-sm-10"> <select id="store_gl" class="form-control store_gl" name="store_gl"> <option>Please Select a GL</option> <option>...</option> </select> </div>
Called in another template,
% layout 'default'; <div id="my template"> ... <%= include 'gl_selector' %> </div>