【问题标题】:Using the Cassette V2 to compile templates jsRender and KnockoutJS templates使用 Cassette V2 编译模板 jsRender 和 KnockoutJS 模板
【发布时间】:2012-09-15 05:45:26
【问题描述】:

我正在迁移到 Cassette 的第 2 版。

但我在网上找不到任何东西可以帮助我配置我的 Cassette 以编译 HTML 模板。

模板

一些模板 jQuery 模板为:

<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="header" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="header">${header}</h3>
    </div>
    <div class="modal-body">
        {{html body}}
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal">${CancelText}</button>
        <button class="btn ${ClassBtn}">${ConfirText}</button>
    </div>
</div>

我会尽快修改它们以使用 jsRender!

其他为 KnockoutJS

<div class="span2">
    <div class="data-block">
        <h4 data-bind="text: Total"></h4>
        <h6>
            <span data-bind="text: Passo.Nome"></span>
            <small class="muted" data-bind="text: Passo.Responsavel">Riderman de Sousa</small>
        </h6>
    </div>
</div>

IConfiguration&lt;BundleCollection&gt;

bundles.AddPerSubDirectory<HtmlTemplateBundle>("HtmlTemplates", b => b.Pipeline = ??? );

【问题讨论】:

    标签: knockout.js asp.net-mvc-4 jsrender cassette precompiled-templates


    【解决方案1】:

    我实际上找到了答案,在 v2 中,一切都是分开的。因此,如果您使用 Less,则必须获取 Cassette.Less nuget 包。与 tmpl 项目相同。

    1 ) 获取 Nuget 包:http://nuget.org/packages/Cassette.KnockoutJQueryTmpl/2.0.0

    2) 配置:

    public class CassetteConfiguration : IConfiguration<BundleCollection>
    {
        readonly KnockoutJQueryTmplPipeline pipeline;
    
        public CassetteConfiguration(KnockoutJQueryTmplPipeline pipeline)
        {
            this.pipeline = pipeline;
        }
    
        public void Configure(BundleCollection bundles)
        {
            bundles.Add<StylesheetBundle>("Content", new FileSearch { Pattern = "*.css;*.less", SearchOption = System.IO.SearchOption.AllDirectories });
            bundles.Add<ScriptBundle>("Scripts");
            bundles.AddPerIndividualFile<ScriptBundle>("Content/js");
    
            bundles.Add<HtmlTemplateBundle>("HtmlTemplates", new FileSearch { Pattern = "*.htm" }, b => b.Pipeline = pipeline);
        }
    }
    

    3 ) 在视图中引用包

    Bundles.Reference("HtmlTemplates");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-22
      • 1970-01-01
      相关资源
      最近更新 更多