Skip to content
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

Correct way to add Liquid attributes to a page from a plugin? #1640

Closed
IQAndreas opened this issue Oct 18, 2013 · 4 comments
Closed

Correct way to add Liquid attributes to a page from a plugin? #1640

IQAndreas opened this issue Oct 18, 2013 · 4 comments

Comments

@IQAndreas
Copy link

This doesn't seem to be covered in the plugin documentation, what is the "correct" way to generate and add Liquid properties to a page from a plugin?

I have only found two examples, and both use this technique:

class Jekyll::Post
        alias :to_liquid_without_comments :to_liquid

        def to_liquid
                data = to_liquid_without_comments
                data['comments'] = StaticComments::find_for_post(self)
                data['comment_count'] = data['comments'].length
                data
        end
end

But as an AS3/Java developer, that sort of code disgusts me. In addition, the example code I provided is not compatible with Octopress which I'm guessing either overrides the to_liquid method itself, or uses an older version of Jekyll.

@parkr
Copy link
Member

parkr commented Oct 19, 2013

No better way at the moment. We want to add hooks ( #1414 ) but haven't gotten around to it yet.

@IQAndreas
Copy link
Author

Bummer, but I'm glad the hooks are on the way.

If you use StackOverflow, feel free to post your answer here and collect the bounty (there are only a few hours left, and it would be a shame to let it go to waste): http://stackoverflow.com/questions/19320448/add-properties-to-a-page-from-a-jekyll-plugin

@parkr
Copy link
Member

parkr commented Oct 20, 2013

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants