浏览器内的 JavaScript 代码编辑器具有语法突出显示功能,支持 Smarty 模板标签?
我在互联网上到处搜索,发现了一些真的很棒的JS具有语法突出显示和缩进等功能的代码编辑器...但似乎没有一个支持 Smarty 模板标签还没有。
CodeMirror 的新 Smarty 模式将是最好的,但如果需要,我会使用不同的编辑器。
我确实找到了这篇博文...但它非常简单,我仍然希望支持混合 HTML/CSS/JS 突出显示,例如 CodeMirror 的 PHP 模式。
我只是想在开始滚动我自己的 CodeMirror 模式之前先咨询一下 SO 蜂巢思维。如果我确实制作了一个新模式(并使用它到达任何地方),我会将其发布在这里。
谢谢!
I have searched high and low on the Interwebs, and found some really awesome JS code editors with syntax highlighting and indentation and more... but none seem to have support for Smarty template tags yet.
A new Smarty mode for CodeMirror would be the best, but I'll use a different editor if I need to.
I did find this blog post... but it is VERY simple, and I would like to still support mixed HTML/CSS/JS highlighting, like the PHP mode for CodeMirror.
I just thought I would check with the SO hive mind before embarking on rolling my own CodeMirror mode. If I do make a new mode (and get anywhere with it) I'll post it here.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我做了一些尝试来获得 smarty 的混合模式,虽然我的工作并不完美,但到目前为止它对我来说已经足够好了。我从 de htmlmixedmode 开始添加 smarty 模式:
仅在 token 函数中切换到 smarty 模式,但是......
您还必须修补其他基本模式( css 、 javascript 和 xml )以将它们停止在 { 字符上,以便您可以退回到标记函数以针对正则表达式( { 后跟一个非空白字符)进行测试。
I made some tries to get a mixed mode with smarty and although my work is not perfect, so far it works well enough for me. I started from de htmlmixedmode to add a smarty mode :
The switch to smarty mode is made in token function only but ...
You also have to patch the other basic modes ( css , javascript & xml ) to stop them on the { character so you can fall back in the token function to test it against a regexp ( { followed by a non blank character ).
这可能会有所帮助。这个周末我为 CodeMirror2 编写了一个 Smarty 模式。看:
http://www.benjaminkeen.com/misc/CodeMirror2/mode/smarty/
我还通过此处的更改分叉了 CodeMirror 项目:
https://github.com/benkeen/CodeMirror2
一切顺利 -
Ben
[编辑:这是现在的一部分主脚本的。我很快就会添加 Smarty/HTML/CSS/JS 模式]。
This may help. I wrote a Smarty mode for CodeMirror2 this weekend. See:
http://www.benjaminkeen.com/misc/CodeMirror2/mode/smarty/
I've also forked the CodeMirror project with my change here:
https://github.com/benkeen/CodeMirror2
All the best -
Ben
[EDIT: this is now part of the main script. I'll be shortly adding a Smarty/HTML/CSS/JS mode].
答案的第二部分:benjamin smarty 文件中的一个补丁,以便能够离开它并退回到 smartymixed 模式。所以这里是 mode/smarty/smarty.js 的修补版本。
第一行检查我们是否被 smartymixed 模式调用,并在此条件上进行测试,允许 smarty 模式像以前一样运行。
The second part of the answer : a patch in benjamin smarty file to be able to leave it and fall back in smartymixedmode. So here is the patched verson of mode/smarty/smarty.js
The 1st line check if we are called by the smartymixed mode and tests are made on this contition, allowing smarty mode to run as before.