Razor template containing page parts that mustache will render on client
Asked Answered
P

1

1

My page contains parts that will render on the client.

The problem I'm having is that razor does not render the parts as I expect them to. For example:

<script type="x-tmpl-mustache" id="filterTemplate">
        <img id="showFilter" src="~/Content/Image/arrow.png" />
</script>

Will not render the ~ sign, only when I place img outside of the script tags will it do as expected.

This is published in different application paths so I need razor to figure out what ~ is and replace it with the application path.

Polynices answered 12/11, 2015 at 7:14 Comment(0)
C
1

You should use @Url.Content helper which will correctly resolve the path relative to the application root:

<script type="x-tmpl-mustache" id="filterTemplate">
        <img id="showFilter" src='@Url.Content("~/Content/Image/arrow.png")' />
</script>
Clambake answered 12/11, 2015 at 7:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.