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

Tag Helpers: add support for @ in a tag helper attribute value #1253

Closed
dougbu opened this issue Oct 6, 2014 · 3 comments
Closed

Tag Helpers: add support for @ in a tag helper attribute value #1253

dougbu opened this issue Oct 6, 2014 · 3 comments

Comments

@dougbu
Copy link
Member

dougbu commented Oct 6, 2014

specifically, add support for a leading @ in an expression the user types. this enables use of expressions that are not model properties e.g.

  @for (var item in Model)
  {
    <input type="text" for="@item" />
  }
@rynowak
Copy link
Member

rynowak commented Nov 20, 2014

See: ProcessAsync_CallsGeneratorWithExpectedValues_ItemsAndMultiple for a test that needs to be updated when this is fixed.

@dougbu dougbu self-assigned this Jan 11, 2015
dougbu added a commit to aspnet/Razor that referenced this issue Jan 12, 2015
- #129 and aspnet/Mvc#1253
- add new `CSharpTagHelperAttributeValueVisitor` that writes the raw expression
- update existing tests to include new line pragmas and updated line mappings
- add tests of embedded `@(...)` and mix that with normal expressions

nits:
- cleanup long lines in `CSharpTagHelperCodeRenderer`
- ease debugging of `LineMapping` values
- improve assertion failures about code mapping miss-matches
- add `GENERATE_BASELINES` reminder to test project.json
dougbu added a commit to aspnet/Razor that referenced this issue Jan 15, 2015
- #129 and support aspnet/Mvc#1253
- add new `CSharpTagHelperAttributeValueVisitor` that writes the raw expression
- add tests of embedded `@(...)` and mix that with normal expressions
- add new resources for errors in `CSharpTagHelperAttributeValueVisitor`
- update baselines to match new code generation

nits:
- cleanup long lines in `CSharpTagHelperCodeRenderer`
- remove a few unused resources

CR comments: Do not `throw` in `CSharpTagHelperAttributeValueVisitor`
- use `ParserErrorSink` instead
- add error if bound non-`string` attribute value is empty (don't handle)
- move `#line` pragma to surround entire bound attribute value assignment
 - need non-`null` `ChunkBlock.Association` value for this to work
- clean up some whitespace special-cases needed for previous approach
dougbu added a commit that referenced this issue Jan 15, 2015
- address #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
@dougbu dougbu changed the title Tag Helpers: support user typing entire RHS of a ModelExpression lambda expression Tag Helpers: add support for @ in a tag helper attribute value Jan 15, 2015
@dougbu
Copy link
Member Author

dougbu commented Jan 15, 2015

previous title was "support user typing entire RHS of a ModelExpression lambda expression"

example attribute values to support:

<select
    asp-for="@(Model.YearsEmployeed)"
    asp-items="@((IEnumerable<SelectListItem>)ViewBag.Items)">
 ...
</select>

<cache vary-by-user="@DateTimeOffset.Now > @(DateTimeOffset.Parse("1 April 2015"))">
 ...
</cache>

dougbu added a commit that referenced this issue Jan 15, 2015
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nit: remove a few unecessary `@`s in .cshtml files
dougbu added a commit that referenced this issue Jan 15, 2015
- address part I of #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
dougbu added a commit that referenced this issue Jan 15, 2015
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nits:
- remove a few unecessary `@`s in .cshtml files
- correct field names & ids in ProductList.cshtml (`foreach` confuses MVC)
 - led to correct valiation attributes as well
dougbu added a commit to aspnet/Razor that referenced this issue Jan 16, 2015
- #129 and support aspnet/Mvc#1253
- add new `CSharpTagHelperAttributeValueVisitor` that writes the raw expression
- add tests of embedded `@(...)` and mix that with normal expressions
- add new resources for errors in `CSharpTagHelperAttributeValueVisitor`
 - write errors using `ParserErrorSink`
- update baselines to match new code generation

nits:
- cleanup long lines in `CSharpTagHelperCodeRenderer`
- remove a few unused resources
dougbu added a commit that referenced this issue Jan 16, 2015
- part I of #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
dougbu added a commit that referenced this issue Jan 16, 2015
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nits:
- remove a few unecessary `@`s in .cshtml files
- correct field names & ids in ProductList.cshtml (`foreach` confuses MVC)
 - led to correct valiation attributes as well
dougbu added a commit that referenced this issue Jan 16, 2015
- part I of #1253 using new Razor capabilities
- update baselines to match latest code generation
- use new `CodeBuilderContext` and `TagHelperAttributeValueCodeRenderer` signatures
- test complex expressions in bound non-string attribute values
dougbu added a commit that referenced this issue Jan 16, 2015
- part II of #1253
- an expected case in template .cshtml files
- expression has name `""`; led to `ArgumentException` in `ModelExpression`
- test `@Model` and `@model.Property` in unit and functional tests
- update baselines to match

nits:
- remove a few unecessary `@`s in .cshtml files
- correct field names & ids in ProductList.cshtml (`foreach` confuses MVC)
 - led to correct valiation attributes as well
@dougbu
Copy link
Member Author

dougbu commented Jan 16, 2015

Fixed with a77d071 and d2fe1eb

@dougbu dougbu closed this as completed Jan 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants