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

Commit c6ebed0

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 f7cac0b commit c6ebed0

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
@@ -94,6 +94,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationModelWebSite", "
9494
EndProject
9595
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TagHelperSample.Web", "samples\TagHelperSample.Web\TagHelperSample.Web.kproj", "{2223120F-D675-40DA-8CD8-11DC14A0B2C7}"
9696
EndProject
97+
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}"
98+
EndProject
9799
Global
98100
GlobalSection(SolutionConfigurationPlatforms) = preSolution
99101
Debug|Any CPU = Debug|Any CPU
@@ -494,6 +496,16 @@ Global
494496
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
495497
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
496498
{2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|x86.ActiveCfg = Release|Any CPU
499+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
500+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
501+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
502+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
503+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|x86.ActiveCfg = Debug|Any CPU
504+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
505+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.Build.0 = Release|Any CPU
506+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
507+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
508+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|x86.ActiveCfg = Release|Any CPU
497509
EndGlobalSection
498510
GlobalSection(SolutionProperties) = preSolution
499511
HideSolutionNode = FALSE
@@ -539,5 +551,6 @@ Global
539551
{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
540552
{6DB9B8D0-80F7-4E70-BBB0-0B4C04D79A47} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
541553
{2223120F-D675-40DA-8CD8-11DC14A0B2C7} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
554+
{B2347320-308E-4D2B-AEC8-005DFA68B0C9} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
542555
EndGlobalSection
543556
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)