将自定义HTML代码段插入MVC视图时,当我开始键入值时,文字替换的编辑将结束。
我错过了什么吗?
我的文字用于替换属性名称两次:
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippet Format="1.0.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>MVC Field Pair</Title>
<Shortcut>mvcfieldpair</Shortcut>
<Description>Inserts an MVC label/input pair</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal Editable="true">
<ID>property</ID>
<ToolTip>Model property</ToolTip>
<Default>myProperty</Default>
</Literal>
</Declarations>
<Code Language="html">
<![CDATA[
<li>
<%= Html.LabelFor(m => m$property$) %>
<%= Html.TextBoxFor(m => m$property$) %>
</li>
$end$]]>
</Code>
</Snippet>
</CodeSnippet>
答案 0 :(得分:3)
相对于<![CDATA[
和]]>
的位置非常重要。我调整了我的片段:
<CodeSnippet Format="1.1.0" xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<Header>
<Title>MVC Field Pair</Title>
<Shortcut>mvcfieldpair</Shortcut>
<Description>Inserts an MVC label/input pair</Description>
<SnippetTypes>
<SnippetType>Expansion</SnippetType>
</SnippetTypes>
</Header>
<Snippet>
<Declarations>
<Literal>
<ID>property</ID>
<ToolTip>Model property</ToolTip>
<Default>myProperty</Default>
</Literal>
</Declarations>
<Code Language="html"><![CDATA[<li>
<%= Html.LabelFor(m => m$property$) %>
<%= Html.TextBoxFor(m => m$property$) %>
</li>$end$]]></Code>
</Snippet>
</CodeSnippet>