waiting-for-dev / front_matter_parser

Ruby library to parse files or strings with a front matter. It has automatic syntax detection.
MIT License
105 stars 12 forks source link

Jekyll: undefined method `to_liquid' #5

Closed ChrisSki closed 6 years ago

ChrisSki commented 6 years ago

Jekyll 3.6.2 Ruby 2.4.1

I'm running into this error when using this with Jekyll. Can't seem to lock down the issue.

Liquid Exception: undefined methodto_liquid' for #...`

Here is the code I'm trying to execute as a Liquid filter in parse_fm.rb

require "front_matter_parser"

module Jekyll
  module ParseFM

    par = ""
    def frontm(string = '')
      par = FrontMatterParser::Parser.new(:md).call(string)
    end
    par
  end
end

Liquid::Template.register_filter(Jekyll::ParseFM)

I'm using it in a liquid template {{yaml | frontm}}

I am simply trying to pass a string like below:

--- blog: https://example.com/page1 background-img: https://example.com/files/image.jpg buttonText: Download download: true---
waiting-for-dev commented 6 years ago

Hi @ChrisSki ,

your issue should be somewhere else. This library does not call to_liquid in any case. It just parses files/strings through regular expressions, but it doesn't use syntax specific libraries. Probably you have an error in your code and you are calling a method on a wrong instance.

ChrisSki commented 6 years ago

@waiting-for-dev sorry about that. I'll take a closer look at my code. My Ruby is lacking of late so I'm not surprised it's me!