Liquid with database?


#1

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


#2

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/mephisto/trunk/app/controllers/application.rb
http://collaboa.techno-weenie.net/repository/file/mephisto/trunk/app/controllers/mephisto_controller.rb

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


Rick O.
http://techno-weenie.net


#3

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/mephisto/trunk/app/controllers/application.rb
http://collaboa.techno-weenie.net/repository/file/mephisto/trunk/app/controllers/mephisto_controller.rb

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


Rick O.
http://techno-weenie.net


#4

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


#5

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?


#6

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?


#7

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


#8

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.


#9

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