在Coldfusion中运行CFGroovy时,如何在服务器端添加纯javascript编译器插件?
我试图说服自己尝试在服务器上构建增强的Jquery移动标记(运行在Coldfusion中运行CFGroovy时,如何在服务器端添加纯javascript编译器插件?,javascript,compilation,coldfusion,server-side,cfimport,Javascript,Compilation,Coldfusion,Server Side,Cfimport,我试图说服自己尝试在服务器上构建增强的Jquery移动标记(运行Coldfusion8),然后尝试使用(Javascript模板引擎)将标记预编译为js字符串,我希望将其作为静态文件发送到服务器 我想我已经把它归结为尝试在Coldfusion中添加插件。以下是我想做的: 从Coldfusion中的以下模板开始: <cfsavecontent variable="renderedResults"> <cfoutput> {##person}{root
Coldfusion8
),然后尝试使用(Javascript模板引擎)将标记预编译为js字符串,我希望将其作为静态文件发送到服务器
我想我已经把它归结为尝试在Coldfusion中添加插件。以下是我想做的:
从Coldfusion中的以下模板开始:
<cfsavecontent variable="renderedResults">
<cfoutput>
{##person}{root}: {name}, {age}{/person}
</cfoutput>
</cfsavecontent>
然后将其另存为someStaticTemplate.js
。该文件被拉入客户端,并填充动态数据
我的问题是在Coldfusion中编译这个
我使用以下命令在服务器上运行Javascript:
<cfimport prefix="g" taglib="../../tags/cfgroovy/" />
35k zipped plugin here
<!--- COMPILE --->
var dustedTemplate = dust.compile( variables.tempLateToCompile, variables.templateName);
<!--- OUT --->
variables.put("renderedResult", dustedTemplate);
</g:script>
为此:
(function() {
dust.register("demo", body_0);
function body_0(chk, ctx) {
return chk.section(ctx.get("person"), ctx, {
"block": body_1
}, null);
}
function body_1(chk, ctx) {
return chk.reference(ctx.get("root"), ctx, "h").write(": ").reference(ctx.get("name"), ctx, "h").write(", ").reference(ctx.get("age"), ctx, "h");
}
return body_0;
})();
如果从技术上讲这是不可能的,我愿意采用其他方法,允许我在服务器上创建一个基于HTML的模板,其中包括占位符,以便我可以在客户端添加动态数据
谢谢 你应该看看
及
快乐编码 如果要使用BB的CFGroovy执行JS,就需要Rhino jar。你把它包括在你的课程路径中了吗。没有。我只是试着用
来学习这个例子。但我跟着帖子,检查了安装的工厂。Rhino在里面,所以我想我会没事的。这是一个类似的可能有用的问题。@krg:这个问题是由。。。我我正在跟踪我在那里得到的信息,但无法使其发挥作用,因此我发布了悬赏,因为有人告诉我我的代码中有什么错误。我对此大发雷霆,无法使其发挥作用。我可以让Rhino加载dust(显然),但它声称“compile”函数不存在。我设法排除了rhino认为dust是什么,它只显示了dust.cache(定义的第一个元素),这可能是一个线索?所以你的问题的答案是,我应该看看我的另一个问题,再加上我在那里提供的链接,试着找出这个主题,试着自己找出它。好。。。我希望得到更多的帮助,或者一些关于我做错了什么的信息。
type: sun.org.mozilla.javascript.internal.JavaScriptException
message: [object Error] (<Unknown Source>#1)
{##person}{root}: {name}, {age}{/person}
(function() {
dust.register("demo", body_0);
function body_0(chk, ctx) {
return chk.section(ctx.get("person"), ctx, {
"block": body_1
}, null);
}
function body_1(chk, ctx) {
return chk.reference(ctx.get("root"), ctx, "h").write(": ").reference(ctx.get("name"), ctx, "h").write(", ").reference(ctx.get("age"), ctx, "h");
}
return body_0;
})();