你能将代码从 CF10 编译器中隔离出来吗? [英] Can you isolate code from being seen from CF10 compiler?

查看:16
本文介绍了你能将代码从 CF10 编译器中隔离出来吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是 Coldfusion 编码的新手,这是我的第二个月,所以请耐心等待.

So I'm new to coding in coldfusion, this being my second month, so bear with me on this.

我雇主的客户希望顺利上传多个处理错误的文件,这意味着即使出现错误,它也会继续完成所有上传.

My employer's client wants to upload multiple files handling errors smoothly, meaning that it will continue on through all the uploads even if there was an error.

因此,使用 CF11,我可以使用带有 continueOnError 和 Errors 可选值的 uploadAll 来轻松处理多个文件.

So with CF11, I can use uploadAll with the optional values of continueOnError and Errors enabled to handle the multiple files easily.

问题是,我雇主的测试服务器仍然只有 CF10,并且可能不会很快更新.所以 continueOnError 和 Error 将在我们的测试服务器上编译失败,但在客户端服务器上不会.

Problem is, is that my employer's testing server is still only CF10, and might not get updated anytime soon. So continueOnError and Error will fail on compile on our testing server, but not on the clients server.

我希望能够做类似的事情:

I would like to be able to do something like:

<cfif SERVER.ColdFusion.ProductVersion gte 11>
    <optimal cffile uploadAll code>
<cfelse>
    <suboptimal cffile uploadAll code>
</cfif>

并且编译没有任何问题.但是测试服务器无论如何都存在代码问题.有什么办法可以在代码中完成吗?如果没有,有没有一种方法可以让我相当轻松地做到这一点……ish?

And not have any problems with compiling. But the testing server has a problem with the code anyway. Is there any way that this can be done within the code? If not, is there a way that I can do this fairly easily...ish?

推荐答案

使用<cfinclude>.

<cfif SERVER.ColdFusion.ProductVersion gte 11>
    <cfinclude template="newWay.cfm">
<cfelse>
    <cfinclude template="oldWay.cfm">
</cfif>

cfbackport 是这样做的:https://github.com/misterdai/cfbackport/blob/主/cfbackport.cfm

This is how cfbackport does it: https://github.com/misterdai/cfbackport/blob/master/cfbackport.cfm

这篇关于你能将代码从 CF10 编译器中隔离出来吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆