This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Tag Helpers: Create an 'environment' Tag Helper #1553
Closed
Description
A new Tag Helper that utilizes the conditional content mode (aspnet/Razor#221) to only render its contents if the current IHostingEnvironment.EnvironmentName
matches the specified name. The target environment names can be specified as a comma separated list via the names
attribute (string). In the case of the environment not currently matching, the contents would not even be executed.
Usage
<environment names="">
</environment>
If the names
attribute is omitted, the contents are always rendered.
Attributes
Attribute Name | Type | Details |
---|---|---|
names | string |
A comma separated list of environment names in which the content should be rendered |
Example
<environment names="Development">
<script src="~/js/file1.js"></script>
<script src="~/js/file2.js"></script>
</environment>
<environment names="Staging,Production">
<script src="~/js/site.js"></script>
</environment>