Using RazorEngine for Text and Html emails -
i'm using razorengine v3.3 create emails using template files (emails sent using sendgrid web api). implemented base template can use own html helpers overriding writeto() method shown here .
my problem emails part html , part text. html templates, use razor's default implementation html-encodes @model values. because of data comes user input. however, can't use same implementation text part html not interpreted when being read.
so way see have 3 options:
- use @raw(model) in text based templates ignore html encoding
- create other base template text templates doesn't encode html
- modify html base template writeto() method doesn't encode anything
the 1st solution seems safest, have 50 text based templates go through, , reduces readability.
the 2nd solution seems cleanest me, prevent use of cache, doing razor.settemplateservice()
reassign right base template ?
what recommend doing ? thanks
Comments
Post a Comment