Forum: Ruby on Rails Liquid with database?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
softwareengineer 99 (Guest)
on 2006-02-08 17:52
(Received via mailing list)
Hello,
  Just wondering if someone here as successfully ported Liquid to use
with a database. I would like to try it out but not sure how Liquid
integrates with current templates.

  Thanks
  Frank
Rick O. (Guest)
on 2006-02-08 18:28
(Received via mailing list)
On 2/8/06, softwareengineer 99 <removed_email_address@domain.invalid> wrote:
> Hello,
>  Just wondering if someone here as successfully ported Liquid to use with a
> database. I would like to try it out but not sure how Liquid integrates with
> current templates.
>
>  Thanks
>  Frank

You mean the liquid template engine?  I'm not sure how others like
Stikipad or Shopify are using them, but my little blog engine Mephisto
uses liquid.

svn co http://techno-weenie.net/svn/projects/mephisto/trunk
# set up database.yml
rake install_mephisto

I don't yet ship with decent templates (mephisto is very rough and not
ready for public consumption), but here's some samples:
http://techno-weenie.net/templates.yml

Here's the liquid rendering in action:
http://collaboa.techno-weenie.net/repository/file/...
http://collaboa.techno-weenie.net/repository/file/...

Liquid cannot access your model's properties, so I wrote a #to_liquid
method to return a hash.

--
Rick O.
http://techno-weenie.net
softwareengineer 99 (Guest)
on 2006-02-09 02:32
(Received via mailing list)
Hi Rick,

  Thanks for your reply.

  I will definitely check the resource links out.

  A quick question, are you using file based liquid templates or storing
them in the database?

  Thanks
  Frank

Rick O. <removed_email_address@domain.invalid> wrote:  On 2/8/06, 
softwareengineer
99  wrote:
> Hello,
>  Just wondering if someone here as successfully ported Liquid to use with a
> database. I would like to try it out but not sure how Liquid integrates with
> current templates.
>
>  Thanks
>  Frank

You mean the liquid template engine?  I'm not sure how others like
Stikipad or Shopify are using them, but my little blog engine Mephisto
uses liquid.

svn co http://techno-weenie.net/svn/projects/mephisto/trunk
# set up database.yml
rake install_mephisto

I don't yet ship with decent templates (mephisto is very rough and not
ready for public consumption), but here's some samples:
http://techno-weenie.net/templates.yml

Here's the liquid rendering in action:
http://collaboa.techno-weenie.net/repository/file/...
http://collaboa.techno-weenie.net/repository/file/...

Liquid cannot access your model's properties, so I wrote a #to_liquid
method to return a hash.

--
Rick O.
http://techno-weenie.net
Rick O. (Guest)
on 2006-02-09 02:42
(Received via mailing list)
>  A quick question, are you using file based liquid templates or storing them
> in the database?

The liquid plugin supports file-based rendering like standard rhtml
files (watch the video).  However, I'm rendering straight from the
database.

--
Rick O.
http://techno-weenie.net
Timothy J. (Guest)
on 2006-09-11 03:04
I'm trying to use Liquid on a new application and it doesn't give me an
idea how to create a to_liquid method on my models. Is there any way to
do it across all models?
Timothy J. (Guest)
on 2006-09-11 03:10
Timothy J. wrote:
> I'm trying to use Liquid on a new application and it doesn't give me an
> idea how to create a to_liquid method on my models. Is there any way to
> do it across all models?

I guess maybe what I need is a Liquid:Drop, but I can't find out any
documentation on how I add this to my Model, controller, or View?

I have a model Caller which I want to pull from. I make a @caller in the
controller, so what is the best way to make a Drop out of it?
Rick O. (Guest)
on 2006-09-11 03:41
(Received via mailing list)
On 9/10/06, Timothy J. <removed_email_address@domain.invalid> wrote:
> controller, so what is the best way to make a Drop out of it?
>
>

Mephisto uses Liquid and Drops.  I just manually create a to_liquid
method on my models that returns a drop.


--
Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com
Timothy J. (Guest)
on 2006-09-11 04:23
Thanks for answering Rick, but I still don't "get it".

In your Articles you have a

 def to_liquid(options = {})
    Mephisto::Liquid::ArticleDrop.new self, options
 end

And similarly in other models, the name of the drop changes based upon
the model. But now of course my problem is that if I drop that in my
model, take out the "Mephisto" and make the drop name appropriate, it
still doesn't work. I wish I really understood the HOW of how this
works, but just getting it to work would be a good step.

Thanks for all your help. Hope I am not sounding too ignorant.
Rick O. (Guest)
on 2006-09-11 04:55
(Received via mailing list)
On 9/10/06, Timothy J. <removed_email_address@domain.invalid> wrote:
>
> Thanks for answering Rick, but I still don't "get it".
>
> In your Articles you have a
>
>  def to_liquid(options = {})
>     Mephisto::Liquid::ArticleDrop.new self, options
>  end

Look in lib/mephisto/liquid/article_drop.rb.

There's no magic really.  Liquid gives you a blank slate, leaving you
to fill in all the gaps.


--
Rick O.
http://weblog.techno-weenie.net
http://mephistoblog.com
This topic is locked and can not be replied to.