public final class Conditionals extends Object implements DependentPlugin
Example of a conditional at-rule:
@
if(ie7) { .test{color:red} }
This block will output its inner statements if its condition matches one of the true conditions in the ConditionalsConfig
instance.
To enable conditionals, register an instance of this plugin during parser setup:
Conditionals conditionals = new Conditionals("ie7"); Omakase.source(input).use(conditionals).process();
For more information on using and configuring conditionals see the main readme file.
ConditionalsConfig
,
ConditionalsCollector
Constructor and Description |
---|
Conditionals()
Creates a new
Conditionals plugin instance with no specified true conditions. |
Conditionals(boolean passthroughMode)
Creates a new
Conditionals plugin instance with passthroughMode set as given. |
Conditionals(Set<String> trueConditions)
Creates a new
Conditionals plugin instance with the given list of true conditions. |
Conditionals(String... trueConditions)
Creates a new
Conditionals plugin instance with the given list of true conditions. |
Modifier and Type | Method and Description |
---|---|
ConditionalsConfig |
config()
Gets the
ConditionalsConfig instance. |
void |
dependencies(PluginRegistry registry)
Registers plugin dependencies.
|
public Conditionals()
Conditionals
plugin instance with no specified true conditions. Be sure to add these true conditions
later via the config()
method if applicable.public Conditionals(boolean passthroughMode)
Conditionals
plugin instance with passthroughMode set as given. See ConditionalsConfig.passthroughMode(boolean)
for more information. Be sure to add the conditions later via the config()
method if applicable.passthroughMode
- Whether passthroughMode should be enabled.public Conditionals(String... trueConditions)
Conditionals
plugin instance with the given list of true conditions. Each string in the set will be
automatically lower-cased for comparison purposes.trueConditions
- List of the strings that should evaluate to "true".public Conditionals(Set<String> trueConditions)
Conditionals
plugin instance with the given list of true conditions. Each string in the set will be
automatically lower-cased for comparison purposes.trueConditions
- Set containing the strings that should evaluate to "true".public void dependencies(PluginRegistry registry)
DependentPlugin
Any plugins you add to the registry in this method will be ordered before this plugin itself.
Keep in mind that only one instance of a plugin can be added in a single parsing operation. You can use PluginRegistry.require(Class)
, PluginRegistry.require(Class, Supplier)
and PluginRegistry.retrieve(Class)
to assist in scenarios where a plugin instance may have already been added.
Dependencies to include can range from refinement dependencies such as SelectorPlugin
and MediaPlugin
to
other custom plugins.
dependencies
in interface DependentPlugin
registry
- The PluginRegistry
instance.PluginRegistry.require(Class)
,
PluginRegistry.require(Class, Supplier)
,
PluginRegistry.retrieve(Class)
public ConditionalsConfig config()
ConditionalsConfig
instance. The ConditionalsConfig
can be used to add, remove, or update the set
of "trueConditions".ConditionalsConfig
instance.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.