# Template system

**URL:** <https://rubytalk.org/t/template-system/6121>\
**Category:** ruby-talk\
**Created:** [25 May 2003 11:13 UTC](https://rubytalk.org/t/template-system/6121 "2003-05-25T11:13:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_S2](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Andreas\_S2](https://rubytalk.org/u/Andreas_S2)\
**Post date:** [25 May 2003 11:13 UTC](https://rubytalk.org/t/template-system/6121/1 "2003-05-25T11:13:04Z")

</div>

Hello,

I need a template system for Plain text (Email), HTML (Web shop) and  
Latex (Invoices). Which one would you recommend?

TIA  
Andreas

> **···**
>
> –  
> AVR-Tutorial, über 350 Links  
> Forum für AVRGCC und MSPGCC  
> -\> [http://www.mikrocontroller.net](http://www.mikrocontroller.net)

---

<div class="post-metadata">

**Author:** ![Jack\_Herrington](https://avatars.discourse-cdn.com/v4/letter/j/ac8455/32.png) [@Jack\_Herrington](https://rubytalk.org/u/Jack_Herrington)\
**Post date:** [25 May 2003 16:22 UTC](https://rubytalk.org/t/template-system/6121/2 "2003-05-25T16:22:50Z")

</div>

ERB is a good choice: [http://raa.ruby-lang.org/list.rhtml?name=erb](http://raa.ruby-lang.org/list.rhtml?name=erb)

-Jack Herrington  
[http://www.codegeneration.net](http://www.codegeneration.net)

> **···**
>
> On 5/25/03 4:13 AM, “Andreas Schwarz” [usenet@andreas-s.net](mailto:usenet@andreas-s.net) wrote:
> 
> > I need a template system for Plain text (Email), HTML (Web shop) and  
> > Latex (Invoices). Which one would you recommend?

---

<div class="post-metadata">

**Author:** ![Dave\_Mail\_Archive](https://avatars.discourse-cdn.com/v4/letter/d/f04885/32.png) [@Dave\_Mail\_Archive](https://rubytalk.org/u/Dave_Mail_Archive)\
**Post date:** [25 May 2003 18:18 UTC](https://rubytalk.org/t/template-system/6121/3 "2003-05-25T18:18:44Z")

</div>

Andreas Schwarz wrote:

> Hello,
> 
> I need a template system for Plain text (Email), HTML (Web shop) and  
> Latex (Invoices). Which one would you recommend?

I use the Template.rb class from RDoc for all these (and other uses  
too). It’s simple, and doesn’t insist on HTML-like tags for markup.

Cheers

Dave

---

<div class="post-metadata">

**Author:** ![Anders\_Borch2](https://avatars.discourse-cdn.com/v4/letter/a/8491ac/32.png) [@Anders\_Borch2](https://rubytalk.org/u/Anders_Borch2)\
**Post date:** [27 May 2003 21:51 UTC](https://rubytalk.org/t/template-system/6121/4 "2003-05-27T21:51:38Z")

</div>

Andreas Schwarz wrote:

> Hello,
> 
> I need a template system for Plain text (Email), HTML (Web shop) and  
> Latex (Invoices). Which one would you recommend?
> 
> TIA  
> Andreas

how about eruby? I know it mostly aims at sgml documents, but it _would_  
let you embed ruby code into almost any document…

> **···**
>
> –  
> dc -e 4dd_od3_ddn1-0nn1dnd+nn3dn1+n3\*1+ddn1+dn2-n5dn1+dnrn1-p | tr  
> 0123456 yorh@k. | dd conv=lcase

---

<div class="post-metadata">

**Author:** ![Shirai\_Kaoru](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@Shirai\_Kaoru](https://rubytalk.org/u/Shirai_Kaoru)\
**Post date:** [28 May 2003 01:21 UTC](https://rubytalk.org/t/template-system/6121/5 "2003-05-28T01:21:46Z")

</div>

Hi.

Do you know amrita - template system for HTML/XML?

[http://raa.ruby-lang.org/list.rhtml?name=amrita](http://raa.ruby-lang.org/list.rhtml?name=amrita)

If you want to use its approach for e-mail or TeX, try misen.

[http://raa.ruby-lang.org/list.rhtml?name=misen](http://raa.ruby-lang.org/list.rhtml?name=misen)

Example 1 (SGML/HTML/XML or various plain text):

> **···**
>
> * * *
> 
> #!/usr/bin/env ruby  
> #-_-ruby-_-  
> require "misen/style"  
> require “misen/util”
> 
> source = '\
> 
> # title will be inserted here
> 
> ' data = { :title =\> "hello world", :body =\> "misen is text template library like Amrita." } print Misen.expand\_text(Misen::STYLE\_SGML, source, data)
> ## =begin Expected:
> 
> # hello world
> 
> misen is text template library like Amrita.
> 
> =end ----------------------------------------------------------------
> ## Example 2 (LaTeX):
> 
> #!/usr/bin/env ruby  
> #-_-ruby-_-  
> require "misen/expand"  
> require "misen/parse"  
> require “misen/style-tex”
> 
> source = \<\<‘EOF’  
> \documentclass{article}  
> \title{\misen:title}  
> \begin{document}  
> \maketitle  
> \begin{misen:body}  
> body will be inserted here  
> \end{misen:body}  
> \end{document}  
> EOF
> 
> data = {  
> :title =\> “hello world”,  
> :body =\> “misen is text template library like Amrita.”  
> }
> 
> parsed = Misen.new\_parser(Misen::STYLE\_TEX).parse\_text(source)  
> printer = Misen::ExpandPrinter.new($stdout)  
> printer.expand\_nodes(parsed, data)
> 
> =begin
> 
> ## Expected
> 
> \documentclass{article}  
> \title{hello world}  
> \begin{document}  
> \maketitle  
> misen is text template library like Amrita.  
> \end{document}
> 
> ## =end
> 
> –  
> Shirai,Kaoru [shirai@korinkan.co.jp](mailto:shirai@korinkan.co.jp)  
> Korinkan Ltd.

---

<div class="post-metadata">

**Author:** ![Andreas\_S2](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Andreas\_S2](https://rubytalk.org/u/Andreas_S2)\
**Post date:** [28 May 2003 20:17 UTC](https://rubytalk.org/t/template-system/6121/6 "2003-05-28T20:17:50Z")

</div>

Shirai,Kaoru wrote:

> Do you know amrita - template system for HTML/XML?
> 
> [http://raa.ruby-lang.org/list.rhtml?name=amrita](http://raa.ruby-lang.org/list.rhtml?name=amrita)
> 
> If you want to use its approach for e-mail or TeX, try misen.

Hmmm, I think that’s a bit oversized and not flexible enough. For  
example I have to chop and/or pad strings for e-mail templates; that  
would be easy in ERuby, but is it possible with misen?

---

<div class="post-metadata">

**Author:** ![Andreas\_S2](https://avatars.discourse-cdn.com/v4/letter/a/f17d59/32.png) [@Andreas\_S2](https://rubytalk.org/u/Andreas_S2)\
**Post date:** [28 May 2003 20:18 UTC](https://rubytalk.org/t/template-system/6121/7 "2003-05-28T20:18:07Z")

</div>

Anders Borch wrote:

> Andreas Schwarz wrote:
> 
> > Hello,
> > 
> > I need a template system for Plain text (Email), HTML (Web shop) and  
> > Latex (Invoices). Which one would you recommend?
> > 
> > TIA  
> > Andreas
> 
> how about eruby? I know it mostly aims at sgml documents, but it _would_  
> let you embed ruby code into almost any document…

Yes, I already thought about it and it seems to be the best solution.

> **···**
>
> –  
> AVR-Tutorial, über 350 Links  
> Forum für AVRGCC und MSPGCC  
> → [http://www.mikrocontroller.net](http://www.mikrocontroller.net)
