Jade allows mixins to have parameters that can be specified on instantiation, very similar to a function with parameters. Do Diet blocks offer any similar functionality to avoid copypasta?
David
Jade allows mixins to have parameters that can be specified on instantiation, very similar to a function with parameters. Do Diet blocks offer any similar functionality to avoid copypasta?
David
Am 23.01.2014 02:00, schrieb David Nadlinger:
Jade allows mixins to have parameters that can be specified on instantiation, very similar to a function with parameters. Do Diet blocks offer any similar functionality to avoid copypasta?
David
A possibility that I have sometimes used is to employ a D function for that:
- void mymixin(int a, int b)
p A: #{a}, B: #{b}
- mymixin(1, 2);
- mymixin(3, 4);
The indentation of the mixed-in code will not be adjusted for the place
where it is inserted, but otherwise this works fine. The "mymixin"
function can also be defined in a separate .dt file that is include
d.
A separate parameterized mixin would of course be nicer, but it feels
like it would require a considerable amount of work.
On Thu, 23 Jan 2014 10:09:09 +0100, Sönke Ludwig wrote:
A possibility that I have sometimes used is to employ a D function for that:
- void mymixin(int a, int b) p A: #{a}, B: #{b} - mymixin(1, 2); - mymixin(3, 4);
Thanks, I knew I missed something obvious!
David