【问题标题】:Display break tags in Jade Mixin在 Jade Mixin 中显示中断标签
【发布时间】:2016-09-23 08:13:19
【问题描述】:

我有一个 JSON 文件,它在 Jade Mixin 中被调用以显示文本。但是,我需要在其中一个 JSON 字段中插入一个中断标记,并且不知道如何在 Jade Mixin 中完成此操作。我似乎无法在任何地方找到相关信息。

这是 JSON 文件:

"features": {

    "employers": {
        "title": "For Employers", 
        "description": "Company corporate financial wellness program is designed to help employers lessen financial stress in the workplace, increase retirement readiness, and strengthen workplace culture.<br />Company offers a holistic approach to corporate financial wellness.",
        "featureList": [
            {
                "iconSlug": "puzzle",
                "title": "Easy Implementation",
                "description": "Company provides a robust, custom marketing and communication plan to help drive program awareness and engagement."
            },
            {
                "iconSlug": "rays",
                "title": "Ongoing Engagement",
                "description": "Get metrics around your employees’ engagement with the program and workplace impact."
            },
            {
                "iconSlug": "dollarSign",
                "title": "Affordable Pricing",
                "description": "Explore our pricing options for all company sizes, including low, per- employee rates that can be paid out of ERISA budgets."
            }
        ],
        "cta": {
            "title": "Contact our team",
            "class": "trigger-emailFormScroll"
        }
}

这是将其引入的 Mixin:

mixin FeaturesModule(config)
h3.lvHeading.lvHeading-size3.lvHeading-main= config.title
h5.lvHeading.lvHeading-size5= config.description

- if (config.cta && typeof config.cta.newPage === "undefined") { config.cta.newPage = true; }

.layout-stdGrid
    each feature, i in config.featureList
        .stdGrid-col8.stdGrid-col-thin.padding-2
            abbr(class= "icon-mktgLight-" + feature.iconSlug)
            h6.lvHeading.lvHeading-size5.lvHeading-main!= feature.title
            span.block= feature.description

- if (config.featuredLink)
    a.link-featured.margin-Y-1.block(href= config.featuredLink.href, name=config.featuredLink.title, target= "_blank")= config.featuredLink.title
- else if (config.cta)
    - if (config.cta.href)
        a.button.button-wide(href= config.cta.href, target= (config.cta.newPage) ? "_blank" : undefined)= config.cta.title
    - else
        - var ctaClass = config.cta.class || "";
        button.button.button-wide(class= ctaClass)= config.cta.title

span.block = feature.description 是我目前正在使用的。让 mixin 解释 break 标记使其不会在页面上打印为文本的最佳方法是什么?

提前致谢。

【问题讨论】:

    标签: javascript node.js pug mixins


    【解决方案1】:

    两种解决方案都可以:

    span.block!=feature.description
    
    span.block!{feature.description}
    

    【讨论】:

    • 谢谢!你能再解释一下这是做什么的吗?
    • 当然。使用“=”是 HTML 转义。使用“!=”不会逃脱。 jade-lang.com/reference/code
    • 如果能解决您的问题,请将我的回答标记为验证
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-30
    • 1970-01-01
    • 2011-12-13
    • 2017-02-23
    • 2014-12-11
    • 1970-01-01
    相关资源
    最近更新 更多