locomotivecms/liquid_extensions

Using liquid_extensions seems to break page saving

peterfealey opened this issue · 6 comments

Using Heroku & this Gem on production errors out with the following and page edits aren't saved

NoMethodError (undefined method `[]' for nil:NilClass):

Pushing locally to Wagon development results in the following:

error => undefined method `context' for #Liquid::Document:0x007ffa08db1410

On the first snippet attempted

did commented

hi @peterfealey, in your Gemfile, use that version, it should work.

gem 'locomotivecms_liquid_extensions', github: 'locomotivecms/liquid_extensions', ref: 'e38a28d', branch: 'hosting'

Unbelievably quick reply there, saving is great and now rendering of my custom type is not happening:

'[Liquid template] trying to call quotation on a content_type object'

Quotation is the name of the field I'm trying to display at random.

                    {% assign random_post = contents.quotes | sample  %}
                    {{ random_post.quotation }}
wasi commented

For me sample is not working either (hosting branch). It seems as it is not called at all. If I include some debug statements in the sample method they are not displayed...
any ideas?

{% assign news_collection = contents.news | sample: 100 %}

engine 2.4.1

gem 'locomotivecms_liquid_extensions', github: 'locomotivecms/liquid_extensions', ref: 'e38a28d', branch: 'hosting'

This works, without needing the extension. It's a bit messy but does the job.

{% assign quote = contents.quotes.first %}
{% assign n = contents.quotes.size | random %}

{% for i in (1..n) %}
{% assign quote = quote.next %}
{% endfor %}

<p>"{{ quote.title }}"</p>
wasi commented

The Problem for me was that the sample Filter is not registered in the hosting branch. I created a pull request the solve that problem.

Hi, I'm experiencing the same problem the founder of this topic. I forked your 'hosting' branch into it's own repo. Tried to add my own tag, uploaded it to the repo, updated the Gemfiles with wagon and engine to point to the new repo. While all of your suggestions got rid of the Nil error, I get absolutely nothing out of my custom tag. No error message, nothing. https://github.com/FuzzySunshine/liquid_extensions/blob/hosting/lib/locomotive/liquid_extensions/tags/test.rb is my new custom tag. https://gist.github.com/FuzzySunshine/aa7b5d332faa26a034d4 is my liquid file from locomotive.