Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 3489c4b

Browse files
committed
Add TextAreaTagHelper and Microsoft.AspNet.Mvc.TagHelpers project
- rest of #1243 and all of #1244 - needs a few utility methods for copying `TagBuilder` to `TagHelperOutput` - but works as-is
1 parent 20d902b commit 3489c4b

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed

Mvc.sln

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApi
100100
EndProject
101101
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TagHelperSample.Web", "samples\TagHelperSample.Web\TagHelperSample.Web.kproj", "{2223120F-D675-40DA-8CD8-11DC14A0B2C7}"
102102
EndProject
103+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TagHelpers", "src\Microsoft.AspNet.Mvc.TagHelpers\Microsoft.AspNet.Mvc.TagHelpers.kproj", "{B2347320-308E-4D2B-AEC8-005DFA68B0C9}"
104+
EndProject
103105
Global
104106
GlobalSection(SolutionConfigurationPlatforms) = preSolution
105107
Debug|Any CPU = Debug|Any CPU
@@ -530,6 +532,16 @@ Global
530532
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
531533
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
532534
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|x86.ActiveCfg = Release|Any CPU
535+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
536+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
537+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
538+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
539+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|x86.ActiveCfg = Debug|Any CPU
540+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
541+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.Build.0 = Release|Any CPU
542+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
543+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
544+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|x86.ActiveCfg = Release|Any CPU
533545
EndGlobalSection
534546
GlobalSection(SolutionProperties) = preSolution
535547
HideSolutionNode = FALSE
@@ -578,5 +590,6 @@ Global
578590
{B2B7BC91-688E-4C1E-A71F-CE948D958DDF} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
579591
{5DE8E4D9-AACD-4B5F-819F-F091383FB996} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
580592
{2223120F-D675-40DA-8CD8-11DC14A0B2C7} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
593+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
581594
EndGlobalSection
582595
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
8+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
9+
<PropertyGroup Label="Globals">
10+
<ProjectGuid>b2347320-308e-4d2b-aec8-005dfa68b0c9</ProjectGuid>
11+
<OutputType>Library</OutputType>
12+
<RootNamespace>Microsoft.AspNet.Mvc.TagHelpers</RootNamespace>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<SchemaVersion>2.0</SchemaVersion>
17+
</PropertyGroup>
18+
<Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
19+
</Project>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using Microsoft.AspNet.Mvc.Rendering;
5+
using Microsoft.AspNet.Razor.Runtime.TagHelpers;
6+
7+
namespace Microsoft.AspNet.Mvc.TagHelpers
8+
{
9+
/// <summary>
10+
/// <see cref="ITagHelper"/> implementation targeting &lt;textarea&gt; elements.
11+
/// </summary>
12+
public class TextAreaTagHelper : TagHelper
13+
{
14+
[Activate]
15+
private IHtmlGenerator Generator { get; set; }
16+
17+
[Activate]
18+
private ViewContext ViewContext { get; set; }
19+
20+
/// <summary>
21+
/// An expression to be evaluated against the current model.
22+
/// </summary>
23+
public ModelExpression For { get; set; }
24+
25+
/// <inheritdoc />
26+
/// <remarks>Does nothing unless user binds "for" attribute in Razor source.</remarks>
27+
public override void Process(TagHelperContext context, TagHelperOutput output)
28+
{
29+
if (For != null)
30+
{
31+
var tagBuilder = Generator.GenerateTextArea(
32+
ViewContext,
33+
For.Metadata,
34+
For.Name,
35+
rows: 0,
36+
columns: 0,
37+
htmlAttributes: null);
38+
39+
if (tagBuilder != null)
40+
{
41+
foreach (var attribute in tagBuilder.Attributes)
42+
{
43+
// TODO: Should special-case the "class" attribute.
44+
if (!output.Attributes.ContainsKey(attribute.Key))
45+
{
46+
output.Attributes.Add(attribute.Key, attribute.Value);
47+
}
48+
}
49+
50+
output.Content = tagBuilder.InnerHtml;
51+
output.SelfClosing = false;
52+
output.TagName = tagBuilder.TagName;
53+
}
54+
}
55+
}
56+
}
57+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"dependencies": {
3+
"Microsoft.AspNet.Mvc.Razor": ""
4+
},
5+
"frameworks": {
6+
"aspnet50": {
7+
"dependencies": {}
8+
},
9+
"aspnetcore50": {
10+
"dependencies": {
11+
"System.Runtime": "4.0.20.0"
12+
}
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)