问题标签 [templating-engine]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
106 浏览

.net - How to change Sitecore's Templating Engine to Sharpy from Razor

Long story short Client provides us with Smarty Templates on Front end. The .Net port of Smarty (Sharpy) is capable of converting all of those templates and use just like we use RAZOR templates. I am unable to figure out how to switch the templating engine to render the Sharpy files instead of RAZOR files so that the Views need not be converted to RAZOR and avoid a lot of code-rewrite that is happening right now.

What I've tried:

  1. I added “sharpy” as valid extension in Sitecore MVC configuration.
  2. I added Sharpy.dll and System.ComponentModel.Composition.dll as reference in the project – required as per the Sharpy documentation.
  3. I added view engine in application_start function of global.asax ( ViewEngines.Engines.Add(new SharpyViewEngine()) );
  4. I added view engine in initialization pipeline – to make sure it’s available

Error:

There is no Build Provider registered for the Extension '.sharpy'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

I am unable to find the exact cause. Googling did not help much as almost all of the users prefer RAZOR to be used. Also need to know what build provider will be applicable here.

UPDATE: Can I find a post/blog on exactly how it is done. Its okay even if it is some other templating engine! I may be able to get around even if that is available.

P.S.: I am new to both .Net/Visual Studio and Sitecore, so any help appreciated

0 投票
1 回答
448 浏览

jekyll - 在 Jekyll 中多次重复字符串

如何在 Jekyll 中多次重复字符串?

例如:在 Python 中,您可以"hello" * 5获取'hellohellohellohellohello'. 在 Jekyll 中有比这更简单的方法来做同样的事情。

例子

假设您要显示星级,并且您正在使用<i class="fa fa-star"></i>来显示每颗星。因此,要显示 5 星评级,您会这样做。

单个页面上可能显示了许多评级,因此您将使用该 for 循环的多个实例。

0 投票
1 回答
762 浏览

symfony - 使用嵌套包含树枝

在我的header.twig

在我的 item-nav.twig

header.twig 包含在 base.twig 中。我在 base.php 文件中渲染了 base.twig。我可以在哪里添加数据array来处理data.urldata.name?在 base.php 中?或者我再次渲染文件php?谢谢你。

基础.php

0 投票
4 回答
8981 浏览

go - 如何缩进包含模板的内容

我正在使用 go 模板为 kubernetes 创建 yaml 定义。我正在尝试嵌套模板,但遇到了无法重用定义的问题,因为包含时缩进是错误的。即,在一种情况下,内容需要缩进,但在另一种情况下不需要。如何控制包含内容的缩进?

下面的例子。我正在重用 pod.tmpl,在第一种情况下,它可以按原样包含在内。在第二种情况下,我需要缩进整个内容,使其成为服务成员

0 投票
1 回答
261 浏览

html - 模板中的 HTML 元素属性默认值支持

是否有模板系统允许为 HTML 元素的属性定义默认值?任何包含给定 HTML 元素并使用给定模板生成的页面都将生成 HTML,其中引用元素的引用属性的值设置为定义的默认值。

假设我希望将“form”元素的“method”属性的默认值设置为“post”。只有在页面没有明确定义“方法”属性时才应该这样做。

0 投票
0 回答
36 浏览

flask - 如何使用 jinja2 从模板中获取动态字段?

对于模板:“Hi {{ name }}, whats your {{ age }}”,我需要动态字段为 ['name', 'age']

0 投票
1 回答
2076 浏览

javascript - 添加过滤器以在 Nunjucks 中动态格式化日期值

我如何检查一个值是否是 Nunjuck 中的一个日期,以便我可以动态添加一个日期过滤器来控制它的显示方式。

例如:

提前感谢您对此的任何指示。

0 投票
1 回答
4120 浏览

python - 使用 jinja2 创建表

我正在尝试使用 jinja2 创建一个(乳胶)表。我定义了一个宏来帮助我创建表:

我可以像这样使用模板:

我非常喜欢这些宏的工作方式。然而,问题是我想通过一个符号而不是在每一行之后播放一个符号join来获得宏的结果。&基本上现在我有这个:

而我想得到这个:

是否可以对宏结果使用过滤器?是否有其他方法可以生成一个表格,其中每个单元格都是另一个 jinja2 模板,具体取决于参数?

0 投票
1 回答
56 浏览

angularjs - 如何将服务器根据请求提供的指令附加到运行的角度应用程序

我有许多使用速度模板引擎生成的 angularJs 指令

根据请求,我想提供相应的指令并将其附加到 angular。

基本上我不想捆绑所有指令,而是我只想使用需要的指令(服务并使用)

0 投票
1 回答
163 浏览

php - 渲染布局和页面树枝文件

索引.php

基地.twig

page.twig

问题:

extends 关键字的问题。我可以单独打印页面或基本内容。但我无法使用扩展或包含或嵌入来打印它们。

我正在使用定制的 php 系统。我将代码包装到 try 块中,我的例外是;

私人'rawMessage'(Twig_Error)=>字符串'模板“base.twig”未定义。' (长度=32)