Transforms html to add configuration data as hidden input fields
The path of the yaml file with the browser configuration you want to be embed can be anywhere in the project. The only restriction is that all configuration settings have to be second level key/value pairs under a single top level entry.
config/default.config.yaml
# Something unrelated
forward_build_to_vagrant: true
# to-be embedded configs
browser_configuration_settings:
hello: world
The transformer takes the following five (5) configuration parameters, the first four (4) of which are required:
-
entry_points
: Which files to transform (required, takes a yaml list). -
config_path
: Path of file with the browser configurations to be embedded into html (required). -
config_key
: The key under which the aforementioned configs are located (required). -
matcher
: String or regex (see below) used to find configuration placeholders to replace in the transformation (required). -
regex
: Whether to use regex or not (optional, default: false).
dependencies:
[...]
html_config_injector: any
transformers:
[...]
- html_config_injector:
entry_points:
- web/index.html
- web/other.html
config_path: config/default.config.yaml
config_key: browser_configuration_settings
matcher: BrowserConfig
regex: false
Place the placeholder you have defined earlier into your html.
Continuing with the example above, our placeholder is BrowserConfig
:
web/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Website</title>
<p>Some content.</p>
BrowserConfig
Run pub build
on your application.
If everything worked, the transformed files will be in the build
directory.
Continuing with the example above:
build/web/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Website</title>
<p>Some content.</p>
<input type="hidden" name="hello" value="world">
None at the moment.