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

Make template path available as data attribute #2667

Merged
merged 2 commits into from Jul 28, 2016

Conversation

@floehopper
Copy link
Contributor

commented Jul 28, 2016

Description

Trello card: https://trello.com/c/X7t256s9

This PR makes the relative path to a template available in each of the NodePresenter sub-classes, i.e. StartNodePresenter, QuestionPresenter & OutcomePresenter. This is then added to an appropriate HTML element as a data attribute, debug-template-path.

The plan is to use this in a bookmarklet to annotate content with a link to the underlying ERB template in the smart-answers repo. This should make it easier for Content Designers to edit the templates directly themselves.

I hope to add functionality to do something similar for partial templates, but I thought that this PR is useful in its own right.

External changes

There should not be any visible changes. However, if you view the source of any Smart Answers page, you should be able to see a data attribute named debug-template-path.

floehopper added 2 commits Jul 26, 2016
Make relative_erb_template_path available on all node presenters
We want to surface this information in a tool to help Content Designers find the
template relating to a specific bit of content.
Make template path available as data attribute on HTML pages
We want to surface this information in a tool to help Content Designers find the
template relating to a specific bit of content.

The plan is to write some JS in a bookmarklet or the GOV.UK Chrome extension
which will depend on these data attributes being available.
@chrisroos

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2016

I'm going to review this now.

@chrisroos chrisroos self-assigned this Jul 28, 2016

@chrisroos

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2016

Looks good to me, @floehopper!

@floehopper floehopper merged commit da7ee66 into master Jul 28, 2016

1 check passed

default "Build #5869 succeeded on Jenkins"
Details

@floehopper floehopper deleted the make-template-path-available-as-data-attribute branch Jul 28, 2016

floehopper added a commit that referenced this pull request Jul 28, 2016
Add function to annotate content with link to template on Github
This JavaScript relies on the `debug-template-path` data attributes made
available in #2667. This idea is to call the new function from a bookmarklet or
the GOV.UK Chrome extension.

I wanted to add the new function in a separate file, but I couldn't get this to
work. So for the moment I've added it in the existing `smart-answers.js` file.

Ideally I would've added some unit tests around the function. However, we don't
have any such tests at the moment, so it would be a fair bit of work.

Today is my last day working on Smart Answers, I wanted to get this code live so
the Content Designers could start using it. Since it's not critical
functionality I think not having tests is OK for the moment.
floehopper added a commit that referenced this pull request Jul 28, 2016
Add function to annotate content with link to template on Github
This JavaScript relies on the `debug-template-path` data attributes made
available in #2667. This idea is to call the new function from a bookmarklet or
the GOV.UK Chrome extension.

I wanted to add the new function in a separate file, but I couldn't get this to
work. So for the moment I've added it in the existing `smart-answers.js` file.

Ideally I would've added some unit tests around the function. However, we don't
have any such tests at the moment, so it would be a fair bit of work.

Today is my last day working on Smart Answers, I wanted to get this code live so
the Content Designers could start using it. Since it's not critical
functionality I think not having tests is OK for the moment.
@floehopper

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2016

Note that the bookmarklet link can be found on this page.

floehopper added a commit that referenced this pull request Aug 2, 2016
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
ikennaokpala added a commit that referenced this pull request Aug 2, 2016
Add function to annotate content with link to template on Github
This JavaScript relies on the `debug-template-path` data attributes made
available in #2667. This idea is to call the new function from a bookmarklet or
the GOV.UK Chrome extension.

I wanted to add the new function in a separate file, but I couldn't get this to
work. So for the moment I've added it in the existing `smart-answers.js` file.

Ideally I would've added some unit tests around the function. However, we don't
have any such tests at the moment, so it would be a fair bit of work.

Today is my last day working on Smart Answers, I wanted to get this code live so
the Content Designers could start using it. Since it's not critical
functionality I think not having tests is OK for the moment.
andrewgarner added a commit that referenced this pull request Nov 29, 2017
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
andrewgarner added a commit that referenced this pull request Nov 29, 2017
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
chao-xian added a commit that referenced this pull request Dec 12, 2017
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
chao-xian added a commit that referenced this pull request Dec 14, 2017
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
chao-xian added a commit that referenced this pull request Dec 16, 2017
Annotate content rendered from flow partials w/ path to template
In #2667 we started annotating the content rendered from flow templates with the
path to the source template via a data attribute, `debug-template-path`.

This commit annotates the content rendered from flow *partial* templates with
the path to the source template via a similar data attribute,
`debug-partial-template-path`. The plan is to use it in a JavaScript function
like the one added in #2670 so that Content Designers can easily find the
template relating to specific content in the GitHub repository.

In order to achieve this, the `PartialTemplateWrapper` is wired up to
`ActionView::PartialRenderer` using `PartialTemplateRenderInterceptor` which
were introduced in earlier commits.

I've added a Rails functional test to act as an "integration" test to check
everything is wired up correctly. In particular this should protect against
breakages due to changes in `ActionView::PartialRenderer` and changes in
govspeak or kramdown.

There didn't seem much point in including the annotation in the regression test
artefacts and so I've introduced an environment variable to disable the
annotation in that case. This also has the benefit that I haven't had to update
all the regression test artefacts which were generated using one or more partial
templates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.