Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared templates #70

Merged
merged 10 commits into from Jun 9, 2015
Merged

Add shared templates #70

merged 10 commits into from Jun 9, 2015

Conversation

quis
Copy link
Contributor

@quis quis commented Jun 8, 2015

This documentation…

image

…is now generated from this Jinja template

<div class="question">
  <label for="question-2" class="question-heading{% if hint is defined %}-with-hint{% endif %}">
    {{ question }}
  </label>
  {% if hint is defined %}
    <p class="hint">
      {{ hint }}
    </p>
  {% endif %}
  {% if large %}
    {% if max_length_in_words is defined %}
      <div class="word-count">
        <textarea class="text-box text-box-large" name="{{ id }}" id="{{ id }}" data-max-length-in-words="{{ max_length_in_words }}">{{ value }}</textarea>
      </div>
    {% else %}
      <textarea class="text-box text-box-large" name="{{ id }}" id="{{ id }}">{{ value }}</textarea>
    {% endif %}
  {% else %}
    <input type="text" name="{{ id }}" id="{{ id }}" class="text-box" value="{{ value }}" />
  {% endif %}
</div>

And the templates can be used in other apps, like so:

image
(uses Jinja's with extension)

The aim of this pull request is to allow sharing of templates between our apps

It does this by:

  • Add Jinja templates for all the design patterns in the toolkit
  • Refactors the toolkit to generate the example markup from the Jinja templates and generate an example of the data passed to the template

This owes some debt to the work that @edds and @dsingleton did with GOV.UK components.

This commit also does some renaming of the patterns to reflect exactly what they do. eg search-results (plural) is a template for rendering a list of search results, whereas page-heading (singular) is a template for rendering a single page heading. This commit only renames the examples and documentation, not the actual toolkit files (so it won't be a breaking change at this stage).

quis added 3 commits June 8, 2015 16:12
This commit does two main things:
- Add Jinja templates for all the design patterns in the toolkit, which can
  be used by any application that requires them
- Refactors the toolkit to generate the example markup from the Jinja templates
  and generate an example of the data passed to the template

This owes some debt to the work that @edds and @davidsingleton did with
GOV.UK components (http://govuk-component-guide.herokuapp.com/)

This commit also does some renaming of the patterns to reflect exactly what they
do. eg search-results (plural) is a template for rendering a list of search
results, whereas page-heading (singular) is a template for rendering a single
page heading. This commit only renames the examples and documentation, not the
actual toolkit files.
Where possible, naming of templates should be consistent with:
- examples
- stylesheets
- javascript files
- This pattern was created (but not merged) prior to this piece of
  work
@@ -87,7 +94,41 @@ def render_page(self, input_file):
partial['pageTitle'] +
" - Digital Marketplace frontend toolkit"
)
if "examples" in partial:
if (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we remove the brackets from this and line 105 to match the style adopted for the rest of this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brackets gone as of 44d922e

@tombye
Copy link
Contributor

tombye commented Jun 9, 2015

Other than the comments above I've just got the following points:

I think the id parameter passed into patterns with radio buttons should be changed to name. It's used for that attribute in the HTML and appears in the HTTP parameters too. I think calling it name makes that usage more obvious.

The README should be updated to explain how the templates are part of the toolkit. Probably some updates to the Example markup section and maybe a new section near Sass compilation to explain where you need to work on HTML and where the template data is kept.

@quis
Copy link
Contributor Author

quis commented Jun 9, 2015

@tombye Readme and naming of parameters to selection buttons added in 550de71 and 977ccc6 respectively.

@tombye
Copy link
Contributor

tombye commented Jun 9, 2015

Managed not to say, this is brilliant work. Looking forward to pulling it down into the apps.

👍

tombye added a commit that referenced this pull request Jun 9, 2015
@tombye tombye merged commit 39617fc into master Jun 9, 2015
@tombye tombye deleted the add-shared-templates branch June 9, 2015 13:04
@dsingleton
Copy link

This is 👌 ✖️ 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants