“VS Code Beautify CFM – cfset tags” 可以翻译为 “VS Code美化CFM – cfset标签”。

huangapple go评论57阅读模式
英文:

VS Code Beautify CFM - cfset tags

问题

我已经在VS Code中安装了Beautify扩展,它对HTML和大多数ColdFusion代码都运行良好,但我似乎无法配置的一件事情是<cfset>标签。
当我们有<cfset var myVar = "some value" />时,它运行正常。
如果我们有<cfset var myVar = "some value">(没有闭合的/>),它会将其视为应该缩进,所以我们最终得到:

<cfset var myVar = "some value">
<cfset var myVar = "some value">
<cfset var myVar = "some value">

我理解解决方案是手动关闭所有标签,但我们有成千上万的页面。有人有配置忽略这些标签,或者更好的是,关闭它们的方法吗?

谢谢

英文:

I have installed the Beautify extension in VS code and it works great for HTML and most ColdFusion code but the one thing I cannot seem to configure is the <cfset> tag.
When we have <cfset var myVar = "some value" /> it works fine.
If we have <cfset var myVar = "some value"> (without the closing /> ) it treats is like it should be indented and so we end up with:

&lt;cfset var myVar = &quot;some value&quot;&gt;
     &lt;cfset var myVar = &quot;some value&quot;&gt;
          &lt;cfset var myVar = &quot;some value&quot;&gt;

I understand that the solution would be to close all of the tags manually, but we have thousands sitewide. Does anyone have a configuration to ignore these, or better yet, close them?

Thank you

答案1

得分: 1

我遇到了一个非常类似的问题,不得不关闭各种标签。所以我创建了一个正则表达式来替换文件编辑器中的每个出现,例如 VsCode 中的“编辑”>“替换文件”命令,使用正则表达式过滤器。这可能对你也有用。请先备份源代码,并小心使用,因为我需要使用它的源代码不是很大。此外,此正则表达式还将更改更多单个 cftags,例如“”,“”,“”等,并关闭它们。根据需要调整正则表达式。

正则表达式:

/(&lt;cf)(set|else|abort|include|queryparam|header|mailparam)(.*?)(?:\s*\/|)&gt;/

替换为:

$1$2$3 /&gt;
英文:

I had a very similar issue and had to close various tags. So I've created a RegEx to replace every occurrence within a file editor, such as VsCode with the command to &quot;Edit&quot; &gt; &quot;Replace in files&quot; und using the RegEx filter. That may work for you also. Please backup your source code first and please use with care, because the source code I've needed to use it wasn't too big. Also, this RegEx will change more single cftags, e.g. &lt;cfinclude&gt;, &lt;cfheader&gt;,&lt;cfdump&gt;, etc. and close them also. Adapt the RegEx as needed.

RegEx:

/(&lt;cf)(set|else|abort|include|queryparam|header|mailparam)(.*?)(?:\s*\/|)&gt;/

Replace with:

$1$2$3 /&gt;

huangapple
  • 本文由 发表于 2023年5月25日 23:19:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76333896.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定