-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update documentation for the different helper methods
This updates the documentation to remove references to .govspeak.erb files and to make suggestions of which helper method (text_for, govspeak_for, html_for) in each scenario. Along the way I noticed that the label field may not be working (issue prior to these changes) so I left a note about that so the next person who wants it can investigate. I removed the information on error_* as I believe that is mostly set on a custom basis so doesn't need to be included in the general documentation.
- Loading branch information
Showing
6 changed files
with
145 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
# ERB templates | ||
|
||
Content is defined in `render_content_for` blocks and with the name of the intent of the content: | ||
Content is defined using one of three helpers to indicate the format: | ||
|
||
```erb | ||
<% render_content_for :title do %> | ||
Some amazing title | ||
<% text_for :title do %> | ||
This is plain text, any HTML characters used will be espaced | ||
<% end %> | ||
``` | ||
|
||
The type of content can be explicitly set with the `format:` option: | ||
```erb | ||
<% govspeak_for :body do %> | ||
This uses the GOV.UK markdown dialect, govspeak, and will be converted to | ||
HTML. | ||
<% end %> | ||
``` | ||
|
||
```erb | ||
<% render_content_for :title, format: :html do %> | ||
<h1>Some amazing title</h1> | ||
<% html_for :body do %> | ||
<p>This is HTML, used when we need fine grained control over content</p> | ||
<% end %> | ||
``` | ||
|
||
We support Govspeak (`:govspeak`), plain text (`:text`) and HTML (`:html`). See docs for template pages for the default formats of different content blocks. | ||
For examples of which of these to use in which contexts see relevant documentation for different contexts: | ||
|
||
* [Landing page templates](erb-templates/landing-page-template.md) | ||
* [Question templates](erb-templates/question-templates.md) | ||
* [Outcome templates](erb-templates/outcome-templates.md) | ||
|
||
We remove all leading spaces from the content in the `render_content_for` blocks for Govspeak and Text formats. This allows us to indent the content in the `render_content_for` blocks without having to worry about it affecting the generated HTML when it's processed using Govspeak. | ||
|
||
Any state variable defined in the flow is available to be used in the ERB template. See [storing data](storing-data.md) for the various ways that you can set state variables. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
# Outcome templates | ||
|
||
Outcome templates live in `lib/smart_answer_flows/<flow-name>/outcomes/<outcome-name>.govspeak.erb`. | ||
Outcome templates live in `lib/smart_answer_flows/<flow-name>/outcomes/<outcome-name>.erb`. | ||
|
||
## Content types | ||
|
||
The templates can contain content for any of the following keys: | ||
|
||
### `:title` | ||
|
||
* Default format is `:text` | ||
* Used as the heading (currently "h1") | ||
|
||
### `:body` | ||
|
||
* Default format is `:govspeak` | ||
* Used as the main text | ||
|
||
### `next_steps(govspeak)` | ||
|
||
* Default format is `:govspeak` | ||
* Used to generate "next steps" content (at top of a right-hand sidebar) | ||
|
||
## Example | ||
Used as the h1 heading, can only be text. Example: | ||
|
||
```erb | ||
<% render_content_for :title do %> | ||
<% text_for :title do %> | ||
<% unless calculator.has_commodity_code? %> | ||
The product composition you indicated is not possible. | ||
<% else %> | ||
The Meursing code for a product with this composition is 7<%= calculator.commodity_code %>. | ||
<% end %> | ||
<% end %> | ||
``` | ||
|
||
### `:body` | ||
|
||
<% render_content_for :body do %> | ||
Used to generate the main content. Expected to be govspeak or HTML. Example: | ||
|
||
```erb | ||
<% govspeak_for :body do %> | ||
<% if calculator.has_commodity_code? %> | ||
Use these four digits together with the ten-digit commodity code from Trade Tariff. | ||
<% end %> | ||
<% end %> | ||
``` | ||
|
||
### `next_steps` | ||
|
||
Used to generate the "next steps" content (at the top of the right-hand sidebar). Expected to be govspeak or HTML. Example: | ||
|
||
```erb | ||
<% govspeak_for :next_steps do %> | ||
Find out what happens to [ownerless property](/unclaimed-estates-bona-vacantia "Ownerless property (bona vacantia)") | ||
<% end %> | ||
``` |
Oops, something went wrong.