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

Convert uk-benefits-abroad to use ERB templates for questions #2156

Merged

Conversation

floehopper
Copy link
Contributor

No description provided.

@floehopper floehopper force-pushed the convert-uk-benefits-abroad-to-use-erb-templates-for-questions branch from c924b3c to 99023c9 Compare November 19, 2015 16:50
@floehopper
Copy link
Contributor Author

I've rebased this against master (resolving the conflicts) and force-pushed. Hopefully that should fix the build for this branch.

@chrisroos
Copy link
Contributor

Looks good to me.

@chrisroos chrisroos self-assigned this Nov 19, 2015
@chrisroos chrisroos added the LGTM label Nov 19, 2015
This should make it easier to convert to rendering questions using ERB
templates.
We will no longer have access to phrases once we convert to rendering questions
via ERB templates. This will make that conversion easier.
This results in more aesthetically pleasing HTML and should make it easier to
convert the flow to use ERB templates for questions.

There is one `hint` in the YAML file which is two sentences on two different
lines with a blank line in between. Presumably the idea was that this would be
converted into two paragraph tags by Govspeak. However, attributes like `hint`
have never (?) been processed by Govspeak, so this would always have been
rendered as a single paragraph tag. Thus it's reasonable for me to combine it
all onto a single line.

I've updated the regression test artefacts and checksums accordingly.
I ran the following command:

    $ rails r script/convert-question-i18-yaml-to-erb-templates.rb lib/smart_answer_flows/uk-benefits-abroad
    Writing template: which_country.govspeak.erb (WARNING: contains interpolation)
    Writing template: going_or_already_abroad.govspeak.erb
    Writing template: which_benefit.govspeak.erb
    Writing template: working_for_a_uk_employer.govspeak.erb
    Writing template: eligible_for_smp.govspeak.erb
    Writing template: employer_paying_ni.govspeak.erb
    Writing template: do_either_of_the_following_apply.govspeak.erb
    Writing template: working_for_uk_employer_ssp.govspeak.erb
    Writing template: eligible_for_tax_credits.govspeak.erb
    Writing template: tax_credits_children.govspeak.erb
    Writing template: tax_credits_currently_claiming.govspeak.erb
    Writing template: tax_credits_why_going_abroad.govspeak.erb (WARNING: contains interpolation)
    Writing template: iidb_already_claiming.govspeak.erb
    Writing template: db_claiming_benefits.govspeak.erb
    Writing template: is_claiming_benefits.govspeak.erb
    Writing template: is_either_of_the_following.govspeak.erb
    Writing template: is_abroad_for_treatment.govspeak.erb
    Writing template: is_work_or_sick_pay.govspeak.erb
    Writing template: is_any_of_the_following_apply.govspeak.erb
    Writing template: jsa_how_long_abroad.govspeak.erb
    Writing template: tax_credits_how_long_abroad.govspeak.erb (WARNING: contains interpolation)
    Writing template: esa_how_long_abroad.govspeak.erb (WARNING: contains interpolation)
    Writing template: db_how_long_abroad.govspeak.erb (WARNING: contains interpolation)
    Writing template: is_how_long_abroad.govspeak.erb

    WARNING: i18n YAML file contains phrases
      * going_abroad_country_question_title: "Which country are you moving to?"
      * already_abroad_country_question_title: "Which country are you living in?"
      * going_abroad_how_long_question_title: "How long are you going abroad for?"
      * already_abroad_how_long_question_title: "How long will you be living abroad for?"
      * why_going_abroad_title: "Why are you going abroad?"
      * why_already_abroad_title: "Why have you gone abroad?"
      * disability_benefits_how_long_question_title: "How long will you be abroad for?"
      * already_abroad_text_two: " or permanently"

    Deleting i18n YAML: uk-benefits-abroad.yml

    Now insert `use_erb_templates_for_questions` at top of flow: uk-benefits-abroad.rb
Since #2098 & #2112, apostrophes rendered via `SmartAnswer::ErbRenderer` have
not been HTML-escaped. Now that we are rendering question content via this
renderer, we need to update the regression test artefacts for question pages
accordingly.

I ran the following commands to do this:

    $ find test/artefacts/uk-benefits-abroad -name '*.html' -print0 | xargs -0 sed -i .bak "s/'/'/g"
    $ git clean -fd test/artefacts/uk-benefits-abroad/**/*.bak
These were not dealt with automatically by the conversion script.
The change to ERB templates has introduced a few extra newlines in the
question page HTML, but none of them affect the content viewable by the user.

I verified that the changes were all only blank lines using the following
command:

    $ git diff --ignore-blank-lines
Re-generating the checksums has removed the i18n YAML file and added the new
question templates as I expected.
@chrisroos chrisroos force-pushed the convert-uk-benefits-abroad-to-use-erb-templates-for-questions branch from 99023c9 to f6206f6 Compare November 19, 2015 18:21
@chrisroos
Copy link
Contributor

I've rebased this on master and force pushed in preparation for merging.

chrisroos added a commit that referenced this pull request Nov 19, 2015
…use-erb-templates-for-questions

Convert uk-benefits-abroad to use ERB templates for questions
@chrisroos chrisroos merged commit 24f7805 into master Nov 19, 2015
@chrisroos chrisroos deleted the convert-uk-benefits-abroad-to-use-erb-templates-for-questions branch November 19, 2015 18:24
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.

2 participants