【问题标题】:perl, mason, working and passing variablesperl,梅森,工作和传递变量
【发布时间】:2018-03-27 05:29:17
【问题描述】:

我正在尝试将“mason”变量传递给在 HTML 之前运行的 Perl 自动处理程序脚本。 这可能吗?

<!--- MASON -->
<html>
<body>
    <%init>
        my $sub_headline = 'this is text';
    </%init>
    ###HEADER###
</body>
</html>

<!--- AUTOHANDLER --->
my $m_header = '<div class="m-portlet__head">
<div class="m-portlet__head-caption">
  <div class="m-portlet__head-title">
    <h3 class="m-portlet__head-text">###TITLE###</h3>
  </div>
  <p>$sub_headline</p>
</div><!-- /.caption -->
</div><!-- /.head -->';
$html   =~ s/###HEADER###/${m_header}/i;

【问题讨论】:

  • 带js和液体
  • 我对 Mason 一点也不熟悉,但我怀疑 regex 是这里的答案。等待认识梅森的人过来。我建议你做一些研究。现在,您的问题看起来像是免费为我工作请求。
  • 感谢收看。我整晚都在旋转我的齿轮。我第一次使用正则表达式,没有积极的结果。
  • 那么请edit 提出问题并向我们展示您的尝试。另见minimal reproducible example 和How to Ask。

标签: perl mason


【解决方案1】:

最终为标头制作了一个组件,并为传入的 arg 添加了一个条件。然后打印正确的 HTML。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-03
    • 1970-01-01
    • 2011-08-16
    • 1970-01-01
    相关资源
    最近更新 更多