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

[phub] Support if statements for optional form fields in announcement templates #102

Open
KashifSaadat opened this issue Jul 28, 2017 · 2 comments
Labels

Comments

@KashifSaadat
Copy link
Contributor

KashifSaadat commented Jul 28, 2017

Announcement templates allow you to add an optional form field. Currently you have two outcomes with such a setup.

  1. Form field {{potato}} is filled in with SOMETEXT:
Bacon ipsum dolor amet salami bresaola: SOMETEXT
  1. Form field {{potato}} is left blank (it leaves the variable reference in when the field is empty):
Bacon ipsum dolor amet salami bresaola: {{potato}}

Suggest adding in capability to parse if blocks like mustache templating supports:

{{#potato}}
    Optional field filled in: {{potato}}
{{/potato}}
{{^potato}}
    End of announcement.
{{/potato}}
@KashifSaadat KashifSaadat changed the title [phub] Having optional announcement form fields currently doesn't add much value [phub] Support if statements for optional form fields in announcement templates Jul 28, 2017
@jits
Copy link
Contributor

jits commented Jul 28, 2017

Yeah, this is a good spot @KashifSaadat – something that I considered when initially building this. We have two options:

  1. Make form fields set to required by default (for announcements in particular), or
  2. Support conditional blocks, as you suggest

I wanted to avoid adding in a templating engine just for this (currently we just do a string find and replace). So option (2) is a bit more heavyweight, and we should only add it if there's a clear need / use case for it. Personally I'd like to avoid adding this :)

For now, option (1) seems to be a good stepping stone. The reason I didn't initially add this is because I DRYed up the fields-editor component from the support request templates and reused it for announcement templates. So we'd need to add a config option to this component to lock the required field or make it configurable (not difficult to do, just something that needs to be introduced with a bit of care).

@jits jits added the bug label Jul 28, 2017
@KashifSaadat
Copy link
Contributor Author

Yup that makes sense, option 1 will be easiest and cleanest to implement. Supporting if blocks would only really be for some edge case scenarios, but I can't see a strong argument for it at the moment and people can just work around it by making a new template.

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

No branches or pull requests

2 participants