docutils / reStructuredText模板功能 [英] docutils/reStructuredText template features
问题描述
如何在我的 .rst
文件中自定义占位符实际值?
How could I customize placeholders in my .rst
file with actual values?
例如,我有 example.rst
包含以下内容的文件:
For example, I have example.rst
file with following content:
Header
------------------------------------
${custom_text}
我要替换 $ {custom_text}
属性,值这是通过运行以下命令定制属性
的值:
I want to replace ${custom_text}
property with the value this is the value of custom property
by running following command:
rst2html example.rst -o example.html -Dcustom_text="this is the value of custom property"
另外我想知道是否可以使用 .properties
文件自定义模板?例如,我想运行 rst2html example.rst -o example.html -p example.properties
命令使用 example.properties
具有以下内容的文件:
Also I wonder whether it is possible to customize template using .properties
file? For example, I would like to run rst2html example.rst -o example.html -p example.properties
command using example.properties
file with following content:
custom_text=this is the value of custom property
有可能吗? reStructuredText是否支持模板功能?
Is it possible? Does reStructuredText support template features at all?
编辑:请注意,我想从命令行自定义模板或使用常规 .properties
文件(可以由Ant / Maven构建管理工具使用)。
Please note that I want to customize template from command line or using conventional .properties
file (can be used by Ant/Maven build management tool).
推荐答案
reStructuredText文件中的替换是使用 替换
指令。例如:
Substitution in reStructuredText files is performed using the replace
directive. For example:
I am using |RST|.
.. |RST| replace:: reStructuredText
将导致文本
我正在使用reStructuredText。
I am using reStructuredText.
您可以使用 include
指令定义替换列表模板在一个单独的文件。例如,给出以下两个文件:
You could use the include
directive to define a list of substitution templates in a separate file. For example, given the following two files:
example.rst :
Header
======
.. Include templates from external file (this is a comment).
.. include:: properties.rst
I can include text, like |my custom text|, from other files.
properties.rst
.. |my custom text| replace:: "example text"
将导致文档:
我可以从其他文件中添加文本,如示例文本。
I can include text, like "example text", from other files.
这里我使用命令 rst2html.py example.rst
来生成HTML输出。
Here I have used the command rst2html.py example.rst
to generate the HTML output.
这篇关于docutils / reStructuredText模板功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!