Skip to content
This repository has been archived by the owner on Apr 5, 2018. It is now read-only.

Using liquid_extensions seems to break page saving #5

Open
peterfealey opened this issue May 27, 2014 · 6 comments
Open

Using liquid_extensions seems to break page saving #5

peterfealey opened this issue May 27, 2014 · 6 comments

Comments

@peterfealey
Copy link

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
Copy link
Member

did commented May 27, 2014

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

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

@did did closed this as completed May 27, 2014
@did did reopened this May 27, 2014
@peterfealey
Copy link
Author

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
Copy link

wasi commented Jun 13, 2014

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'

@peterfealey
Copy link
Author

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
Copy link

wasi commented Jun 23, 2014

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.

@StephanieSunshine
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants