【发布时间】:2017-08-09 22:18:05
【问题描述】:
我有一些组件已分解为多个较小的文件。主文件使用data-sly-include 属性包含它们。
我想在主文件和包含文件中生成包含当前文件名的 HTML cmets,这样当我查看呈现的输出时,我可以很容易地分辨出哪个文件生成了输出。比如:
... some HTML from the template or other components...
<!-- begin /path/to/main/file.html -->
<div>
This is from the main file
<!-- begin /path/to/main/includes/first.html -->
<p>This is fromt the first include</p>
<!-- end /path/to/main/includes/first.html -->
<!-- begin /path/to/main/includes/second.html -->
<p>This is fromt the second include</p>
<!-- end /path/to/main/includes/second.html -->
now we're back in the main file
<!-- end /path/to/main/file.html -->
我可以看到如何获取当前页面的路径,但那是包含我的组件的资源;我想要组成组件的文件的路径。有什么方法可以在 Sightly 中做到这一点?
【问题讨论】: