-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Tag Helpers: Create an 'environment' Tag Helper #1553
Comments
why do you have Also, can this
one my author
and for the enviroment example:
or maybe better |
is there a way to implement fallback environment when the enviroment does not match any of listed names ? I'm afraid we may see lots of duplicated code... or lots of enviroment clauses. Is the view really the responsable to use one or another ? |
@Bartmax agree on name/names, I'll change that. You could certainly build a more generic conditional/if tag helper yourself, but we're not planning on doing it. We see environment being something people often conditionally render content on so we're promoting it as a first class tag helper, but fundamentally we don't to go super generic in the tag helpers (and have Razor end up looking like Spark). |
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 thenames
attribute (string). In the case of the environment not currently matching, the contents would not even be executed.Usage
If the
names
attribute is omitted, the contents are always rendered.Attributes
string
Example
The text was updated successfully, but these errors were encountered: