diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index 3e44c811c1..dea14d134c 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -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 diff --git a/app/views/pages/values.html.erb b/app/views/pages/values.html.erb index 329a08d40b..3c326758c4 100644 --- a/app/views/pages/values.html.erb +++ b/app/views/pages/values.html.erb @@ -1,15 +1,27 @@

Values

- <% Value.data.each do |key, value| %> + - <% end %> + + + <% Value.data.each do |key, value| %> + + + + + <% end %> +
- - $<%= key %>$ - + Key - <%= value %> + Value
+ + $<%= key %>$ + + + <%= value %> +
diff --git a/docs/content.md b/docs/content.md index cab009eeae..d3ee990dcd 100644 --- a/docs/content.md +++ b/docs/content.md @@ -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) @@ -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 +

Useful dates

+

+ The opening date for applications is <%= v :dates_example_opening %>. +

+``` + +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: @@ -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. \ No newline at end of file +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.