discourse/plugins/discourse-narrative-bot
Krzysztof Kotlarek e2f9b7dd6f FIX: Narrative Bot certificates are ERB templates (#8174)
There are at least two ways of rendering templates outside of the controller. The first one is Rails way enabled with Rails 5 https://evilmartians.com/chronicles/new-feature-in-rails-5-render-views-outside-of-actions
The downside of this method is that all variables need to be passed as params (I could find a way to pass the whole context)

Another way is to use instance_eval described in Erubi documentation
https://github.com/jeremyevans/erubi#usage - it works perfectly fine, however, I didn't feel very confident about using eval unless necessary.

An additional benefit of using `ApplicationController.render` is that if Rails would change the ERB engine in the future, this code should still work.

If you want to test it on your local, you need to be signed in and then that two URLs are generating certificates:
http://localhost:3000/discobot/certificate.svg?date=Oct+07+2019&type=standard&user_id=1
http://localhost:3000/discobot/certificate.svg?date=Oct+07+2019&type=advanced&user_id=1

Dev: https://dev.discourse.org/t/discourse-narrative-bot-should-not-be-storing-giant-strings/17130
2019-10-09 17:45:01 +11:00
..
assets/javascripts/initializers REFACTOR: Move app-events:main to service:app-events (#8152) 2019-10-04 10:06:08 -04:00
autoload/jobs DEV: Upgrading Discourse to Zeitwerk (#8098) 2019-10-02 14:01:53 +10:00
config Update translations 2019-10-08 12:25:24 +02:00
db/fixtures DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
lib/discourse_narrative_bot FIX: Narrative Bot certificates are ERB templates (#8174) 2019-10-09 17:45:01 +11:00
public/images remove mistakenly checked file 2017-10-20 07:07:51 -07:00
spec FIX: Improve Onebox detection (#8019) 2019-09-10 13:59:48 +03:00
plugin.rb DEV: use 'user_created' discourse event instead of 'after_commit' model callback. 2019-10-04 10:48:49 +05:30