The state of string interpolation
Jacob Carlborg
doob at me.com
Sat Dec 8 12:10:34 UTC 2018
On 2018-12-07 04:29, Steven Schveighoffer wrote:
> vibe.d does string interpolation in it's diet templates, but the rub is
> that you have to pass in an alias to the variables you want to be
> visible in the interpolation. So it requires a very un-DRY solution, and
> also doesn't work with arbitrary expressions.
I haven't used the diet templates but I have used views, the
corresponding system, in Ruby on Rails quite a lot. There it's not
required to pass in the variables to the view/template. But in my
experience it's best to create an explicit object that will contain all
the data you need from the view. This usually leads to better code than
passing in a bunch of different modules, which you usually end up adding
view specific methods to. Following this module you would only need to
pass in one object/struct value.
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list