Substitution Tags(替换标签)

  % $cd_count = ; # this is embedded Perl
You have <% $cd_count %> CDs.

Escaping substitutions(转义替换), 两个字符 h(html),u(URL),n(不转义)

<textarea name="foo"><% $foo_data | h %></textarea>
Homepage: <a href="redirect?url=<% $homepage | u %>">   

Embedded Perl: % Lines and <%perl> Blocks (嵌入perl)

  % foreach my $person (@people) {
Name: <% $person->{name} %>
Age: <% $person->{age} %>
Height: <% $person->{height} %>
Weight: <% $person->{weight} %>
% }

如果有多行则可以用<%perl> </%perl>

If you have more than a few lines of Perl code in a row, however, it is probably best to use a Perl block instead
<%perl>
my @words = $sentence =~ /\b(\S+)\b/g;
my @small_words = grep { length $_ <= } @words;
my @big_words = grep { length $_ > } @words;
</%perl>

Calling Other Components: <& &> Tags   调用其它组件

调用组件

<& /path/to/menu &>
<& $component &>
<& menu, width => , admin => &>

可以用+或者()表示为表达式运行

<& ( component_path_returner( ) ) &>
<& +component_path_returner( ) &>

<%init> blocks , 初始化块

 It is currently <% $temp %> degrees.
<%init>
my ($temp) = $dbh->selectrow_array("SELECT temperature FROM current_weather");
</%init>

<%args>

<%args>
$color #是必需要传入数据的
$size =>
@items => ( , , 'something else' )
%pairs => ( key1 => , key2 => 'value' )
</%args>

获取提交表单值 $ARGS{'submit.x'}

% foreach (sort %ARGS) {
<% $_ %>
% } % foreach (sort @_) {
<% $_ %>
% }

可通过http传递获取参数

the mason book

												

maston总结的更多相关文章

随机推荐

  1. BOM DOM区别 来源

    DOM 是为了操作文档出现的 API,document 是其的一个对象:BOM 是为了操作浏览器出现的 API,window 是其的一个对象. BOM是浏览器对象模型,DOM是文档对象模型,前者是对浏 ...

  2. Android OS Startup

    OS puts emphases on how to provide interfaces to user's APPs for using hardware device in the conven ...

  3. SQL Server2005修改计算机名后不能发布订阅

    在一台安装有SQL Server2005的计算机上,更改计算机名后,在发布订阅的时候提示如下错误报告: 由于需要需要配置一个发布订阅,可是一直报告:" sql server 复制需要有实际的 ...

  4. BIN文件对象数据库,直接存储对象做数据库,小型项目用它准没错

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.I ...

  5. JavaScript 面向对象编程(二):继承

    Javascript面向对象编程(二):构造函数的继承 这个系列的第一部分,主要介绍了如何"封装"数据和方法,以及如何从原型对象生成实例. 今天要介绍的是,对象之间的"继 ...

  6. postman 1—官网下载及安装

    测试过程中构造批量数据方式: 1 业务只关联数据库单张表,那么可以通过sql插入数据 也可以通过接口构造. 2 业务关联多张数据库表.要在多张表插入数据且保持数据的一致性,此时通过接口批量发送请求构造 ...

  7. CFG的定义

    最近在CMU上NLP,好吧 对于见了很多年的CFG(Context-Free Grammar)发现又搞不懂是什么了 教材上写的是: mathematical system for modeling c ...

  8. 将Apache2.4手动安装成Windows的服务

    将Apache2.4手动安装成Windows的服务 可以选择在安装Apache时自动将其安装为一个服务.如果选择"for all users",那么Apache将会被安装为服务. ...

  9. Spring boot 异常处理配置

    1.    新建Maven项目 exception 2.   pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0&quo ...

  10. fluent Python

    1.1 Python风格的纸牌 Python collections模块中的内置模块:namedtuple https://www.liaoxuefeng.com/wiki/0013747381250 ...