DEV Community

artydev
artydev

Posted on

Mithril in Razor Pages

Sometimes I fill easier to use Mithril for rendering list in Razor pages.
Notice how Mithril gets the target element width id list. We simply put the term list without even quoting it, awesome.

@{
    string[] data = new string[] { "Raph", "Mila", "Cath", "Marcel" };
}

<div id="list"></div>

<script>
    const  data = @Html.Raw(Json.Serialize(data));
    m.render(list, m("ul", data.map(name => m("li", `Hello ${name}`))))
</script>

Top comments (0)