-
Notifications
You must be signed in to change notification settings - Fork 0
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
Documentation clarification / possible forloop issue? #1
Comments
Also having issues with This issue in liquid-node suggests that it should be possible. |
You would do this if you wanted to do things with the engine directly (like custom filters). The readme shows how you register a custom filter to prepend text. If you're not using a lot of Jekyll filters, you likely won't need this.
If you need to do this, you can choose to put the javascript file in the scripts folder, where hexo will load it during initialization. See https://hexo.io/docs/plugins.html.
Can you provide more of an example? Some code to demonstrate whats not working? |
This would be an example of where you might reference the exported Engine property. var Liquid = require("liquid-node");
var renderer = require('hexo-renderer-liquid');
var engine = renderer.Engine;
engine.registerFileSystem(new Liquid.LocalFileSystem("./views")); |
Thanks for your patience. I got a plugin script rolling, got the file system thing working after making some tweaks to your example code. I made a custom filter with your sample code in the readme. Worth noting that adding your sample code doesn't change any functionality; prepend works out of the box. I guess my confusion in both cases but the filesystem in particular is 'why do I need to configure things to make it work', but now that I'm looking into it, including files might be more of a Jekyll thing than a Liquid thing? If that's true, this makes sense. Only thing left are those forloops! I have a YAML file in - name: Foo
- name: Bar
- name: Baz And here's some output that's meant to test various ways of outputting data: {% for name in site.data.test %}
<p>
{{ forloop.length }}
{{ name }}
{{ site.data }}
</p>
{% endfor %} The output I get is
So, it's getting the data and counting it right, but something is off about how it's being displayed. I'll poke around liquid_node a bit, see if I need to be adding something to my script. |
Worth noting that this works as expected: {% assign my_array = "foo|bar|baz" | split: "|" %}
<p>{{ my_array }}</p>
{% for item in my_array %}
<p>{{ item }}</p>
{% endfor %} So it's something about pulling in external content, be it from the YAML file or pulling in stuff from page.posts. |
@BrendanBerkley I suspect that you're getting an object back from {% for item in site.data.test %}
<p>{{ item.name }}</p>
{% endfor %} |
Hello! Looking to make the move from Jekyll to Hexo but want to keep the templating system, which led me here.
Since I'm new to both your plugin and Hexo, I'm wondering if you could clarify some things in your readme?
{{ forloop.length }}
to count correctly so I know that it's partially right, but I couldn't get it to output anything other than[object Object]
.Anyways, I'm glad this exists. I'm moving to Node for build purposes, but it's nice to have a chance at retaining the familiarity of Liquid. Thanks for your work!
The text was updated successfully, but these errors were encountered: