-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_config.yml variables from asciidoctor.attributes can't also be used as 'site.asciidoctor.attributes.foo' in jekyll templates #137
Comments
That's correct. That's not how this part of the configuration is consumed. It's handled specially. If you know of a way to make these settings available to Liquid, I'm open to considering it. But it doesn't work as you describe because it was not a requirement for the design of this plugin. I think the SiteDrop would need to be enhanced somehow to allow access to it, but Liquid in general is very strange in what objects it permits to be navigated (very different from Slim and Haml). |
I am in no way a jekyll/liquid expert, so if you're saying this is expected behavior then so be it -- feel free to close. I opened the issue only because:
For example, my
...and if i drop Random experiments with other variables (even deeply nested variables) in |
cassandra pointed out that we don't need a _data/adoc-attributes.yml.template file, _config.yml variables can be used as site.foo variables in our templates. So this change removes _data/adoc-attributes.yml.template and puts the asciidoctor config back into a _config.yml.template instead. This involves less magic and makes it easier to find all the jekyll config options. Unfortuntately there seems to be a bug/oddity in how the asciidoctor jekyll plugin is initializatin itself, so we can't just use variables like site.asciidoctor.attributes.foo in our templates, we have to redundently declare "foo" again in the _config.yml: asciidoctor/jekyll-asciidoc#137
That's extremely misleading of those docs because it does not take into account plugin configuration. It should say that any configuration that isn't part of a plugin configuration is likely (but not always) to be available to Liquid. So it's a generalization. |
Liquid templates can access simple structures, but they cannot access complex structures like a Hash with symbol keys. It requires special handling. There are various reasons why we have to use a Hash, and, for that matter, modify the raw site configuration. It has to do with how Jekyll is implemented and the lifecycle it exposes to plugins. We are limited by its design. I'd argue this is just the way this plugin works. Having said all that, there is a way to access the attributes you define in asciidoc_attributes: &asciidoc_attributes
foo: bar
asciidoctor:
attributes: *asciidoc_attributes Then you can reference:
Keep in mind, these will be the unprocessed entries. |
understood.
Ahhh... excellent! thank you for the suggestion/pointer to YAML reference - those do solve the problem nicely. |
Now using YAML references based on a tip from mojavelinux: asciidoctor/jekyll-asciidoc#137 (comment)
👍 |
I documented this in the README. See https://github.com/asciidoctor/jekyll-asciidoc#using-asciidoc-attributes-in-a-liquid-template. |
The jekyll docs note that...
...and nested structures such as this onebelow work fine and allow for variables like
{{ site.my_stuff.attributes.foo }}
in liquid templates to be resolved tobar
...However, something about the way the jekyll-asciidoctor plugin is initialized seems to be "eating" it's config and preventing the asciidoctor attribute declarations to be re-used as jekyll variables in liquid templates. So for example with this
_config.yml
snippet......the attribute
{foo}
in anindex.adoc
file will be expanded toyak
but if the liquid template contains the following:the output will be...
The text was updated successfully, but these errors were encountered: