TinyMce 替换模板中的值
TinyMce replacing values in template
我有一个关于在 tinymce 模板中替换值的问题。
我的 index.html
中有以下代码:
<!DOCTYPE html>
<html>
<head>
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
</head>
<body>
<textarea>Next, get a free TinyMCE Cloud API key!</textarea>
<script>
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "template",
toolbar: "template",
templates: [
{title: 'Some title 2', description: 'Some desc 2', url: 'development.html'}
],
template_replace_values: {
username: "Jack Black",
staffid: "991234"
}
});
</script>
</body>
</html>
在我的development.html
里面我有这个:
预览文字
<!-- This will not be inserted -->
<div class="mceTmpl">
<span class="username">This should be replaced?</span>
</div>
如果我对 tinymce 文档的理解正确,文本 "This should be replaced?" 应该替换为 Jack Black。来自 template_replace_values
上的 tinymce 文档:
This is an array of items that controls content replacement in the
inserted templates. The array keys equal the classnames used in the
template. If a template element matches a classname in this array its
contents will be replaced by the array value. TinyMce Docs
这不起作用,让我想知道如何使用该功能。很高兴有任何关于如何完成这项工作的例子。
我不确定该插件是否确实按照文档所述进行操作。我创建了一个 TinyMCE Fiddle,展示了如何使用文档中调用的内容 "snippets" 来完成您需要的操作:
http://fiddle.tinymce.com/QSfaab
我为 TinyMCE 的制造商工作 - 我将跟进我们的工程团队,看看是否可以调整文档以使其使用更清晰。
我有一个关于在 tinymce 模板中替换值的问题。
我的 index.html
中有以下代码:
<!DOCTYPE html>
<html>
<head>
<script src="https://cloud.tinymce.com/stable/tinymce.min.js"></script>
</head>
<body>
<textarea>Next, get a free TinyMCE Cloud API key!</textarea>
<script>
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "template",
toolbar: "template",
templates: [
{title: 'Some title 2', description: 'Some desc 2', url: 'development.html'}
],
template_replace_values: {
username: "Jack Black",
staffid: "991234"
}
});
</script>
</body>
</html>
在我的development.html
里面我有这个:
预览文字
<!-- This will not be inserted -->
<div class="mceTmpl">
<span class="username">This should be replaced?</span>
</div>
如果我对 tinymce 文档的理解正确,文本 "This should be replaced?" 应该替换为 Jack Black。来自 template_replace_values
上的 tinymce 文档:
This is an array of items that controls content replacement in the inserted templates. The array keys equal the classnames used in the template. If a template element matches a classname in this array its contents will be replaced by the array value. TinyMce Docs
这不起作用,让我想知道如何使用该功能。很高兴有任何关于如何完成这项工作的例子。
我不确定该插件是否确实按照文档所述进行操作。我创建了一个 TinyMCE Fiddle,展示了如何使用文档中调用的内容 "snippets" 来完成您需要的操作:
http://fiddle.tinymce.com/QSfaab
我为 TinyMCE 的制造商工作 - 我将跟进我们的工程团队,看看是否可以调整文档以使其使用更清晰。