question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rider not highlighting `hx-controller` and `hx-action` attributes

See original GitHub issue

I’m not sure if this is an Htmx.TagHelpers issue or a JetBrains Rider issue. I am using the Htmx.TagHelpers and they work great. Razor converts the following code into an hx-get="/actual/path/to/controller".

<select class="form-control custom-select"
        asp-for="SchoolId"
        asp-items="Model.Schools"
        hx-get
        hx-controller="SurveySubmissions"
        hx-action="GetTeachersAjax"
        hx-route-surveyId="@Model.SurveyId"
        hx-route-currentTeacherSelection="@Model.TargetId"
        hx-target="#teachers"
        hx-indicator=".htmx-indicator">
    <option value="">Select a School&hellip;</option>
</select>

However, Rider does not pick up the hx-controller and hx-action attributes as tag helper enhanced. Looking at the code for the tag helper, I see they are defined using square brackets.

[HtmlTargetElement("*", Attributes = "[hx-get]")]
[HtmlTargetElement("*", Attributes = "[hx-post]")]
[HtmlTargetElement("*", Attributes = "[hx-delete]")]
[HtmlTargetElement("*", Attributes = "[hx-put]")]
[HtmlTargetElement("*", Attributes = "[hx-patch]")]
public class HtmxUrlTagHelper : TagHelper

If I instead change my code to include the brackets, then Rider bolds the attributes but Razor no longer processes them.

<select class="form-control custom-select"
        asp-for="SchoolId"
        asp-items="Model.Schools"
        [hx-get]
        hx-controller="SurveySubmissions"
        hx-action="GetTeachersAjax"
        hx-route-surveyId="@Model.SurveyId"
        hx-route-currentTeacherSelection="@Model.TargetId"
        hx-target="#teachers"
        hx-indicator=".htmx-indicator">
    <option value="">Select a School&hellip;</option>
</select>

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stevenbenitezcommented, Jun 21, 2022

Yep, works perfectly. Thanks!

1reaction
khalidabuhakmehcommented, Jun 16, 2022

@stevenbenitez HEY IT WORKS NOW! v0.0.18. Turns out I had to compile JetBrains.Annotations into the assembly. The NuGet Package only works for local projects. Give it a try. I just did and it seems to work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inspection Settings | JetBrains Rider Documentation
JetBrains Rider | Settings or Preferences | Editor | Inspection ... This option lets you enable or disable syntax highlighting scheme.
Read more >
Code annotation attributes | JetBrains Rider Documentation
Annotations framework provides a number of attributes described below. ... A method that returns null if the parameter is null, // and not...
Read more >
asp-controller and asp-action attributes not working
I am implementing a project in ASP.NET MVC Core. This does not fire: <a asp-controller="App" asp-action="Trips" class="btn btn- ...
Read more >
Why does Rider think my controller methods are unused?
The application works fine, each of the individual endpoints does its job as expected when triggered by Postman, but for some reason the...
Read more >
Rider, Windows, Resolve symbols between Editor and ...
I open my project on my Mac and Rider resolves all the symbols just fine. The Unity project itself compiles and runs just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found