Login  Register

Re: Pass parameter from AsciiDoc CLI to HAML template

Posted by mojavelinux on May 21, 2020; 6:24pm
URL: https://discuss.asciidoctor.org/Pass-parameter-from-AsciiDoc-CLI-to-HAML-template-tp8023p8031.html

> Very confused why I'm using @document.attr? :env, instead of @document.attr? :env ==, BUT I confirmed the if statement evaluates properly if the var is different.

This code:

if @document.attr? :env, 'localwebassets'

is shorthand for

if (@document.attr :env) == 'localwebassets'

And :env is just shorthand for 'env' (since the method coerces it to a string)

On another note, I don't recommend using the attribute name "env" since that's an intrinsic attribute used by the processor to identify the environment. It won't break your code, but I still recommend using another name.

Best Regards,

-Dan

--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux