Skip to content

Commit

Permalink
Add erb support, update content documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
martyn-w committed Apr 30, 2024
1 parent 81d9159 commit ae55159
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/helpers/content_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ def article_classes(front_matter)
def display_content_errors?
Rails.application.config.x.display_content_errors
end

def value(key)
Value.data[key.to_s]
end
alias_method :v, :value
end
24 changes: 18 additions & 6 deletions app/views/pages/values.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<h1>Values</h1>
<table>
<% Value.data.each do |key, value| %>
<thead>
<tr>
<td>
<code>
$<%= key %>$
</code>
Key
</td>
<td>
<%= value %>
Value
</td>
</tr>
<% end %>
</thead>
<tbody>
<% Value.data.each do |key, value| %>
<tr>
<td>
<code>
$<%= key %>$
</code>
</td>
<td>
<%= value %>
</td>
</tr>
<% end %>
</tbody>
</table>
38 changes: 37 additions & 1 deletion docs/content.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ This documentation aims to be a reference for content editors that want to make
* [Inset text](#inset-text)
* [YouTube Video](#youtube-video)
* [Hero](#hero)
* [Values](#values)
4. [Creating a Blog Post](#creating-a-blog-post)
* [Images](#images)
* [Footers](#footers)
Expand Down Expand Up @@ -287,6 +288,41 @@ hero_bg_color: white
hero_blend_content: true
```

### Values

You can use the Values system to maintain key values (e.g. salaries, dates, fees etc) in a single file, and then use these values throughout the site's content. Set up a list of values in one or more YML files stored in the `config/values/` folder (or sub-folder), for example `config/values/dates.yml`:

```yaml
dates:
example:
opening: 1st September 2024
dates_example_closing: 31/12/2024
```

These values can then be used in markdown files by referencing the value as `$``value_name``$`, e.g. `$``dates_example_opening``$` or `$``dates_example_closing``$`. Note that structured composite keys will be flattened to a single key.

An example markdown implementation might be:

```markdown
# Useful dates
The closing date for applications is $dates_example_closing$. It is important to submit your application in good time.
```

Values can also be used in ERB templates using `<%= value :value_name %>` (or as a shorthand, `<%= v :value_name %>`).

An example ERB implementation might be:

```html
<h1>Useful dates</h1>
<p>
The opening date for applications is <%= v :dates_example_opening %>.
</p>
```

A list of the current values available on the site can be viewed at the `/values` endpoint.

## Creating a Blog Post

Blog posts should be written in Markdown format using the following template as a guide:
Expand Down Expand Up @@ -574,4 +610,4 @@ You can find everywhere a page is linked to by:
## Resolving comments
People can add comments to pull requests in Github which makes it easier to see feedback and keep track of changes. You can also tag people and reply to their comments.
Once you've addressed a comment click on resolve. This hides it from the conversation making it easier to keep track of what's been updated.
Once you've addressed a comment click on resolve. This hides it from the conversation making it easier to keep track of what's been updated.

0 comments on commit ae55159

Please sign in to comment.