You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@buildr.apache.org by Juliano DeCarvalho <ju...@gmail.com> on 2008/09/28 05:56:29 UTC

Using ERB in Docter documents

Hello,

I'm currently working on a Buildr plugin which uses Docter to generate some
files.  With my somewhat limited knowledge of Ruby, I have not been able to
figure out how to pass the ERB templating system my own set of values (a
binding object).  Can someone tell me if its possible to pass the textile
files an object which I can then access in the templates themselves?

I noticed that the common.erb_this() method takes a binding object, but have
not been able to figure out how to use this to my adavantage.  Any help is
apreciated.

Thank you,

- Juliano DeCarvalho

Re: Using ERB in Docter documents

Posted by re...@gmail.com.
Hi Juliano,

I have completely misunderstood your question - sorry.

Have never used Docter, so I must resign this question back to the list :-)

Cheers,
Tal

On 9/29/08, Juliano DeCarvalho <ju...@gmail.com> wrote:
> Hello Tal,
>
> Thank you for your response.  I think I may need to explain myself further.
> I understand the concept of passing a binding to ERB.  What I could not
> figure out is how to do it through Docter.  For example, given the following
> call to docter, how can I pass it the binding object?
>
> <code>
>     collection =
> Collection.new(doc_name).using('doc/site.toc.yaml').include('doc/pages')
>     template   = Docter.template('doc/site.haml').include('doc/css',
> 'doc/images', 'doc/scripts')
>     Docter::Rake.generate 'site', collection, template
> </code>
>
> Thank you again for your time.
>
> - Juliano
>
> On Sun, Sep 28, 2008 at 10:18 PM, Tal Rotbart <re...@gmail.com> wrote:
>
>> Hi Juliano,
>>
>> You might want to look again in the RDocs for ERB:
>> http://ruby-doc.org/core/classes/ERB.html
>> Search for the title "Ruby in HTML" which demonstrates one of the
>> options for passing more than one argument to the template.
>>
>> You can also use OpenStruct to generate a binding object from a Hash.
>>
>> Cheers,
>> Tal
>>
>> On Sun, Sep 28, 2008 at 1:56 PM, Juliano DeCarvalho
>> <ju...@gmail.com> wrote:
>> > Hello,
>> >
>> > I'm currently working on a Buildr plugin which uses Docter to generate
>> some
>> > files.  With my somewhat limited knowledge of Ruby, I have not been able
>> to
>> > figure out how to pass the ERB templating system my own set of values (a
>> > binding object).  Can someone tell me if its possible to pass the
>> > textile
>> > files an object which I can then access in the templates themselves?
>> >
>> > I noticed that the common.erb_this() method takes a binding object, but
>> have
>> > not been able to figure out how to use this to my adavantage.  Any help
>> is
>> > apreciated.
>> >
>> > Thank you,
>> >
>> > - Juliano DeCarvalho
>> >
>>
>

Re: Using ERB in Docter documents

Posted by Assaf Arkin <ar...@intalio.com>.
On Sun, Sep 28, 2008 at 7:50 PM, Juliano DeCarvalho
<ju...@gmail.com> wrote:
> Hello Tal,
>
> Thank you for your response.  I think I may need to explain myself further.
> I understand the concept of passing a binding to ERB.  What I could not
> figure out is how to do it through Docter.  For example, given the following
> call to docter, how can I pass it the binding object?
>
> <code>
>    collection =
> Collection.new(doc_name).using('doc/site.toc.yaml').include('doc/pages')
>    template   = Docter.template('doc/site.haml').include('doc/css',
> 'doc/images', 'doc/scripts')
>    Docter::Rake.generate 'site', collection, template
> </code>

Right now the bindings always point to the context (page or template)
being processed.

Assaf


>
> Thank you again for your time.
>
> - Juliano
>
> On Sun, Sep 28, 2008 at 10:18 PM, Tal Rotbart <re...@gmail.com> wrote:
>
>> Hi Juliano,
>>
>> You might want to look again in the RDocs for ERB:
>> http://ruby-doc.org/core/classes/ERB.html
>> Search for the title "Ruby in HTML" which demonstrates one of the
>> options for passing more than one argument to the template.
>>
>> You can also use OpenStruct to generate a binding object from a Hash.
>>
>> Cheers,
>> Tal
>>
>> On Sun, Sep 28, 2008 at 1:56 PM, Juliano DeCarvalho
>> <ju...@gmail.com> wrote:
>> > Hello,
>> >
>> > I'm currently working on a Buildr plugin which uses Docter to generate
>> some
>> > files.  With my somewhat limited knowledge of Ruby, I have not been able
>> to
>> > figure out how to pass the ERB templating system my own set of values (a
>> > binding object).  Can someone tell me if its possible to pass the textile
>> > files an object which I can then access in the templates themselves?
>> >
>> > I noticed that the common.erb_this() method takes a binding object, but
>> have
>> > not been able to figure out how to use this to my adavantage.  Any help
>> is
>> > apreciated.
>> >
>> > Thank you,
>> >
>> > - Juliano DeCarvalho
>> >
>>
>

Re: Using ERB in Docter documents

Posted by Juliano DeCarvalho <ju...@gmail.com>.
Hello Tal,

Thank you for your response.  I think I may need to explain myself further.
I understand the concept of passing a binding to ERB.  What I could not
figure out is how to do it through Docter.  For example, given the following
call to docter, how can I pass it the binding object?

<code>
    collection =
Collection.new(doc_name).using('doc/site.toc.yaml').include('doc/pages')
    template   = Docter.template('doc/site.haml').include('doc/css',
'doc/images', 'doc/scripts')
    Docter::Rake.generate 'site', collection, template
</code>

Thank you again for your time.

- Juliano

On Sun, Sep 28, 2008 at 10:18 PM, Tal Rotbart <re...@gmail.com> wrote:

> Hi Juliano,
>
> You might want to look again in the RDocs for ERB:
> http://ruby-doc.org/core/classes/ERB.html
> Search for the title "Ruby in HTML" which demonstrates one of the
> options for passing more than one argument to the template.
>
> You can also use OpenStruct to generate a binding object from a Hash.
>
> Cheers,
> Tal
>
> On Sun, Sep 28, 2008 at 1:56 PM, Juliano DeCarvalho
> <ju...@gmail.com> wrote:
> > Hello,
> >
> > I'm currently working on a Buildr plugin which uses Docter to generate
> some
> > files.  With my somewhat limited knowledge of Ruby, I have not been able
> to
> > figure out how to pass the ERB templating system my own set of values (a
> > binding object).  Can someone tell me if its possible to pass the textile
> > files an object which I can then access in the templates themselves?
> >
> > I noticed that the common.erb_this() method takes a binding object, but
> have
> > not been able to figure out how to use this to my adavantage.  Any help
> is
> > apreciated.
> >
> > Thank you,
> >
> > - Juliano DeCarvalho
> >
>

Re: Using ERB in Docter documents

Posted by Tal Rotbart <re...@gmail.com>.
Hi Juliano,

You might want to look again in the RDocs for ERB:
http://ruby-doc.org/core/classes/ERB.html
Search for the title "Ruby in HTML" which demonstrates one of the
options for passing more than one argument to the template.

You can also use OpenStruct to generate a binding object from a Hash.

Cheers,
Tal

On Sun, Sep 28, 2008 at 1:56 PM, Juliano DeCarvalho
<ju...@gmail.com> wrote:
> Hello,
>
> I'm currently working on a Buildr plugin which uses Docter to generate some
> files.  With my somewhat limited knowledge of Ruby, I have not been able to
> figure out how to pass the ERB templating system my own set of values (a
> binding object).  Can someone tell me if its possible to pass the textile
> files an object which I can then access in the templates themselves?
>
> I noticed that the common.erb_this() method takes a binding object, but have
> not been able to figure out how to use this to my adavantage.  Any help is
> apreciated.
>
> Thank you,
>
> - Juliano DeCarvalho
>