Reputation: 149
When inserting a custom HTML code snippet into an MVC view, editing of the literal replacement ends when I begin typing a value.
Am I missing something?
My literal is used twice to replace a property name:
<?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>
Upvotes: 2
Views: 746
Reputation: 149
Position relative to <![CDATA[
and ]]>
is important. I adjusted my snippet:
<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>
Upvotes: 3