Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel
bgColor#ffffff
titleBGColor#ffffff
title最佳实践
Multiexcerpt
MultiExcerptNamestoring scripts

The best practice is to store scripts in your project module. This way the scripts can be stored in a version control system and are automatically part of a controlled software development lifecycle. You can edit them on the file system in your favorite editor that supports syntax highlighting and other helpful features.

While doing development it is sometimes useful to edit scripts in the repository. This method only works with Freemarker scripts. If you bootstrap scripts into the templates workspace they become visible and editable in STK > Templates. All STK scripts follow this model. As you can see from the loading order above a script in the templates workspace will override a script loaded from the classpath. Once added or modified, it is necessary to select the Enable template checkbox to force Magnolia CMS to load the template from the repository.

Image Removed

 

Warning

Editing template scripts in the repository is ideal for evaluation, prototyping or smaller projects. However, it is not maintainable in the long run. Don't do it in a production environment. We strongly recommend that you store the scripts in a version control system and package them into a project module.

 

...

最佳实践是将脚本存储在您的项目模块里,这样脚本可以被存储在一个版本控制系统,并且自动成为一个可控的软件开发周期的一部分。您可以在文件系统里用您喜爱的支持语法高亮及其他特性的编辑器来编辑。

开发时,在内容库里编辑脚本有时候很有用。这种方法只对FreeMarker脚本有效。如果您将脚本导入templates工作区,它们就会在STK > Templates里可见可用。所有的STK脚本都遵循这个模式。您可以从以上的加载顺序看出,在templates工作区里的脚本会覆写从类路径里加载的脚本。一旦被添加或修改,则需要选中Enable template复选框来强迫Magnolia CMS从内容库中加载模板。

Image Added

 

Warning

在内容库里编辑模板脚本对评估,制造原型,或较小的项目比较理想。然后,长期来说这不利于维护。不要在生产环境中这样做。我们强烈建议您在一个版本控制系统中存储脚本,并将它们打包进一个项目模块。

 

参考模板样例 > 编辑模板脚本里更多信息。

STK脚本

STK template scripts are in the classpath of the webapp. Copies are editable in-place in STK > Templates. STK scripts are written in FreeMarker.

...