标签: template-engine

renderArgs在模板中为null!骨架

我有这样的控制器功能

public static void renderCustomersList() {
        System.out.println("renderArgs"+renderArgs.toString());
        render(renderArgs);
    }
Run Code Online (Sandbox Code Playgroud)

在我的groovy模板中

renderArgs $ {renderArgs.toString()}

我在我的控制台中打印了带有值的renderArgs,但是当我传递给模板时,它的打印为null.我想在main.html中使用这些值.我在renderCustomersList.html和main.html中打印了renderArgs,两个模板上的值都为null.可能是什么错误.

groovy template-engine playframework

2
推荐指数
1
解决办法
1887
查看次数

Smarty:templates_c和缓存文件夹之间有什么区别?

有两个文件夹- templates_ccache正在使用的Smarty使用缓存时使用.

我已经启用了缓存,之后,两者都包含某种缓存(恕我直言相同的文件),但仍然有一些PHP,而不是纯HTML.但是,只是好奇这些文件夹有什么区别?Smarty在尝试查找相对缓存文件时首先查找的位置?

php template-engine smarty

2
推荐指数
1
解决办法
3927
查看次数

未定义的玉的数组长度

我有代码,我想在餐厅显示表的数量我的代码是:

#{restaurant.tables.length}
Run Code Online (Sandbox Code Playgroud)

但它不适合我,并错误地"无法读取未定义的属性'长度'.我可以解决这个问题吗?

tables是我从mongodb集合中获取的数组.

我使用mongoosejs"findOne"方法,我的餐厅架构是:

 var restuarantSchema = new Schema({
    name : String,
    details : String,
    owner : String,
    categories : {
       name : String
    },
    users : [],
    tabels: [{
        title: String
    }]
});
Run Code Online (Sandbox Code Playgroud)

javascript template-engine node.js express pug

2
推荐指数
1
解决办法
9408
查看次数

Sencha touch - Ext.XTemplate 如果/否则不起作用

嗨,我是 Sencha touch 的新手。我在Ext.dataview.ListitemTpl. 这就是我设置itemTpl的方式config

itemTpl: new Ext.XTemplate(

            '<div class="featureImageHolder"><img class="featureImage" src="{itemImage}" alt="{itemName}" /></div>',

            '<span class="item">',
                '<h3 class="saleName">{itemName}</h3>',
                '<span class="priceOptions">',
                '<tpl for="prices">',
                    '<span class="priceOptionReg">',
                        '<tpl if="priceOptionDesc">{priceOptionDesc}</tpl> ',
                        '<tpl if="priceOptionReg">{priceOptionReg}</tpl>  ',
                        '<tpl if="priceReg">${priceReg}</tpl>  ',
                        '<tpl if="priceRegSuffix">{priceRegSuffix}</tpl> ',
                    '</span>',
                    '<tpl if="priceSale"><span class="priceOptionSale">',
                        '<tpl if="priceSaleDesc">{priceSaleDesc}</tpl> ',
                        '<tpl if="priceOptionSale">{priceOptionSale}</tpl>  ',
                        '<tpl if="priceSale">${priceSale}</tpl>',
                        '<tpl if="priceSaleSuffix">{priceSaleSuffix}</tpl> ',
                    '</span></tpl>',
                '</tpl>',
                '</span>',
            '</span>',
            '<div class="clear"></div>'
        ),
Run Code Online (Sandbox Code Playgroud)

它运行良好并显示产品列表。但是现在我只需要更改第一条记录的 CSS 类,因为它是一个广告横幅。所以我使用以下 if 语句:

itemTpl: new Ext.XTemplate(
                '<tpl if={isBanner} === true>',
                    '<div class="myTestClass">{itemImage}</div>',

                '<tpl …
Run Code Online (Sandbox Code Playgroud)

javascript template-engine extjs sencha-touch sencha-touch-2

2
推荐指数
1
解决办法
1万
查看次数

在编译时检查属性名称的 Web 模板引擎

我正在寻找一个在运行之前编译模板文件的 Web 模板引擎(任何语言,Java 首选)。它应该在我的模板中检测未知的属性名称和路由。例如:

<h1>{{hello}}</h1> 
Run Code Online (Sandbox Code Playgroud)

如果我渲染的模型上没有相应的字段,应该给出编译错误

java template-engine properties web

2
推荐指数
1
解决办法
419
查看次数

将Freemarker集成到Spring mvc时出错

我试图将Freemarker模板集成到Spring mvc应用程序中.我试过它作为教程中的节目.这是代码,我使用的是freemarker 2.3.15

servletcontext.xml

 <!-- freemarker config -->
    <beans:bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
      <beans:property name="templateLoaderPath" value="/WEB-INF/views/"/>
    </beans:bean>

    <!--
      View resolvers can also be configured with ResourceBundles or XML files. If you need
      different view resolving based on Locale, you have to use the resource bundle resolver.
    -->
    <beans:bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
      <beans:property name="cache" value="true"/>
      <beans:property name="prefix" value="/WEB-INF/views/"/>
      <beans:property name="suffix" value=".ftl"/>
    </beans:bean>
Run Code Online (Sandbox Code Playgroud)

它给出了错误:

1. Build path is incomplete. Cannot find class file for org/springframework/ui/freemarker/
 FreeMarkerConfigurationFactory

2.No setter found for property 'templateLoaderPath' in class 
 'org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer' …
Run Code Online (Sandbox Code Playgroud)

java template-engine freemarker spring-mvc

2
推荐指数
1
解决办法
2232
查看次数

在init或处理函数中读取模板?

我正在为网站编写基本服务器.现在,我面临一个(对我而言)难以解决的表现问题.在init()函数中读取模板文件是否更好?

// Initialize all pages of website
func init(){
 indexPageData, err := ioutil.ReadFile("./tpl/index.tpl")
 check(err)
}
Run Code Online (Sandbox Code Playgroud)

还是在http.HandlerFunc

func index(w http.ResponseWriter, req *http.Request){
  indexPageData, err := ioutil.ReadFile("./tpl/index.tpl")
  check(err)
  indexPageTpl := template.Must(template.New("index").Parse(string(indexPageData)))
  indexPageTpl.Execute(w, "test")
}
Run Code Online (Sandbox Code Playgroud)

我想在第一个例子中,在服务器启动后,您无需访问磁盘并提高请求的性能.
但在开发过程中,我想刷新浏览器并查看新内容.这可以通过第二个例子来完成.

有人拥有最先进的解决方案吗?或者从性能的角度来看是什么?

performance template-engine http go

2
推荐指数
2
解决办法
153
查看次数

如何在 Mustache 的循环表示中获取数组的根值?

使用 Mustache 模板时,循环表示如下:

数据:

{animals: [
  {name: "cat"}, 
  {name: "dog"}, 
  {name: "pig"}
]}
Run Code Online (Sandbox Code Playgroud)

模板:

{{#animals}}
  <p>{{name}}</p>
{{/animals}}
Run Code Online (Sandbox Code Playgroud)

结果:

<p>cat</p>
<p>dog</p>
<p>pig</p>
Run Code Online (Sandbox Code Playgroud)

但是如果要使用的值直接写在数组下,如何访问呢?我写的意思是

数据:

{animals: [
  "cat", 
  "dog", 
  "pig"
]}
Run Code Online (Sandbox Code Playgroud)

结果:

<p>cat</p>
<p>dog</p>
<p>pig</p>
Run Code Online (Sandbox Code Playgroud)

要得到上面的结果,我该如何编写模板?

问候,

html template-engine mustache

2
推荐指数
1
解决办法
502
查看次数

如何在树枝模板中的变量之间添加空格?

这是一个非常简单的问题,但我还没有找到答案。

这段代码:

{{ civilite }}{{ nom }}{{ prenom }}
Run Code Online (Sandbox Code Playgroud)

打印 MRJOHSONBarry

我想在变量之间添加空格,我该怎么做?

php template-engine symfony twig

2
推荐指数
2
解决办法
8935
查看次数

messageSource不替换模板中的所有参数

我有代码:

messageSource.getMessage("some.key",new Object[]{30,31},Constants.LOCALE)
Run Code Online (Sandbox Code Playgroud)

和键内部属性文件:

some.key=Csv header length ({0}) doesn't correspond the mapping file size {1} .
Run Code Online (Sandbox Code Playgroud)

但结果很奇怪:

Csv header length (30) doesn't correspond the mapping file size {1} .
Run Code Online (Sandbox Code Playgroud)

Fisrt变量被成功替换但第二 - 不是.

为什么第二个论点没有解决?

java spring template-engine resourcebundle internationalization

2
推荐指数
1
解决办法
1457
查看次数