【问题标题】:slim template render title parameterslim 模板渲染标题参数
【发布时间】:2016-03-14 16:18:28
【问题描述】:

我尝试从布局的内容部分推送一些标题参数。

我的内容:

-myTitle = "title"
    == render :slim, :"_layouts/default" do #<<need to push myTitle
      //dynamic content
      section class="body" id="diashow_content" == render :html, :"_body/index"
      //<!-- Modal -->
      //-js

这是我的默认布局:

doctype html
    html
      head
        == render :slim, :"_head/default" #<<need to push myTitle
      body
        //invisible content
        div class="handy"
        section id="curtain" class="static" == render :html, :"_partials/curtain"
        section id="head" class="static" == render :html, :"_partials/head"
        section id="content" class="dynamic"
          == yield
        section id="loading" class="static collapse" == render :html, :"_partials/loading"
        section id="foot" class="static" == render :html, :"_partials/foot"

我的标题所在的默认头像:

meta charset="utf-8"
meta http-equiv="Content-Type" content="text/html"
meta name="keywords" content="test, test2"
meta name="description" content="Ich teste nur"
meta name="robots" content="index,follow"
meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"
meta name="theme-color" content="#0E214F"
==slim :"_head/assets"

title #<< try to get myTitle attribute here

我希望这足够透明,对不起我不愉快的英语技能。 谢谢!

【问题讨论】:

    标签: ruby-on-rails slim-lang


    【解决方案1】:

    您需要将其定义为实例变量,以便在其他模板中可用。

    - @myTitle = "title"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-30
      • 1970-01-01
      相关资源
      最近更新 更多