gpt4 book ai didi

javascript - Gruntjs 更改下划线模板分隔符

转载 作者:数据小太阳 更新时间:2023-10-29 05:55:20 24 4
gpt4 key购买 nike

我正在尝试生成一个 JSP 页面,因为 JSP 使用的模板定界符与下划线使用的相同。

查看文档 --> https://github.com/gruntjs/grunt/wiki/grunt.template#wiki-grunt-template-setDelimiters我可以看到他们有一个功能

grunt.template.addDelimiters(name, opener, closer)

两个问题:

  1. 我应该在哪里调用该函数?
  2. 我可以只更改 grunt.template.process() 的分隔符吗(我有多个,对于其他非 .jsp 模板,默认分隔符就可以了)?

感谢任何帮助。谢谢。

最佳答案

来自 grunt.template.process 的文档:

默认的模板分隔符是 <% %>,但如果 options.delimiters 设置为自定义分隔符名称,则将使用这些模板分隔符。

这基本上意味着您可以使用您之前添加的分隔符的名称调用 grunt.template.process。

例如如果您想在应该完成这项工作的一个处理步骤中使用方括号作为分隔符:

// first add the new delimiters which you want to use
grunt.template.addDelimiters('square-brackets', '[', ']');

// and use it
grunt.template.process(template, {delimiters: 'square-brackets'});

// and use it with the default delimiters (named 'config')
grunt.template.process(template);

关于javascript - Gruntjs 更改下划线模板分隔符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16686652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com