Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lsegal committed Jun 11, 2008
1 parent 85479fb commit 2b03860
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 74 deletions.
16 changes: 0 additions & 16 deletions examples/example2/treate/html/but_i_have.haml

This file was deleted.

5 changes: 5 additions & 0 deletions examples/example2/treate/html/content.haml
@@ -0,0 +1,5 @@
%ol
- all_sections do |s|
%li{:id => s}
:markdown
#{yield}
8 changes: 0 additions & 8 deletions examples/example2/treate/html/header.haml

This file was deleted.

12 changes: 11 additions & 1 deletion examples/example2/treate/html/main.haml
Expand Up @@ -4,4 +4,14 @@
%title Tater Tots

%body
%div= yield
#page
#title
:markdown
#{yield}

#content= yield

#copyright
:markdown
#{yield}

5 changes: 5 additions & 0 deletions examples/example2/treate/html/setup.rb
@@ -0,0 +1,5 @@
inherits 'treate/markdown'

def init
sections 'main', ['title', 'content', ['what_is', 'but_i_have'], 'copyright']
end
40 changes: 0 additions & 40 deletions examples/example2/treate/html/what_is.haml

This file was deleted.

14 changes: 14 additions & 0 deletions examples/example2/treate/markdown/but_i_have.txt
@@ -0,0 +1,14 @@
## But I Already Use Haml / Erubis / Builder and They're Great.

Repeat after me: Tater is _not_ Haml.

### Tater is _not_ Haml.
#### Tater is _not_ Haml.
##### Tater is _not_ Haml.

**Tater** is not a templating engine. It's completely engine-agnostic. In fact, you can use Haml,
Erubis, Builder, Textile, and any other engine you want and still get the benefit of Tater's
_actual_ features. Again, Tater doesn't care about what you're actually displaying in your templates,
just how they're ordered. You can sit a Haml file right next to an ERB file and a Builder file. Tater
doesn't know, or care, that you've done this.

3 changes: 3 additions & 0 deletions examples/example2/treate/markdown/copyright.erb
@@ -0,0 +1,3 @@

_Copyright 2008 Loren Segal._
_All code licensed under the MIT License._
3 changes: 3 additions & 0 deletions examples/example2/treate/markdown/setup.rb
@@ -0,0 +1,3 @@
def init
sections 'title', 'what_is', 'but_i_have', 'copyright'
end
2 changes: 2 additions & 0 deletions examples/example2/treate/markdown/title.txt
@@ -0,0 +1,2 @@
# Welcome to Tater Tots
## Templates for Ruby: The Object-Oriented Templating System
36 changes: 36 additions & 0 deletions examples/example2/treate/markdown/what_is.txt
@@ -0,0 +1,36 @@
## What is This?

**Tater Tots** (or _Tater_ for short) is an _object-oriented_ templating system that doesn't care about
what templating engines you like to use. It's kind of like a meta-templating engine, because it really
only cares about where your templates come from-- not what's in them. All you have to give Tater is
a list of "sections" that make up your template.

#### Wait, Did you say object oriented? _For files?_

Yes. I did. **Tater**'s goal is to bring modularity to your templates by introducing this nifty new concept
called _"Object-Oriented Programming"_. It allows you to essentially "subclass" a template from another one,
inheriting all of the parent template's behaviour. It also allows you to solve another problem common to
complex templates: _coupling_.

Now bear with me here, coupling is considered a common problem in software, but you've probably never heard
someone tell you that your templates files suffer from that problem. Coupling is a necessary dependency from
one module to another, making it impossible to break the two modules apart. So when you directly call a template
from one of your other template files, you are creating exactly that kind of coupling.

How do we solve template coupling? **Sections**.

#### Sections?

You might know these as _partials_. But partials are **ugly**. Partials get lost deep inside your templates
and never get out. Then, when you need to create a derivative template using everything but that one partial,
you have to make yet another partial which includes the first one, or use some fancy if/then/else logic with
crazy local variables to hide it from the original template. This gets messy fast, because it's all done
from _inside_ the template.

Sections are as simple as a list. In fact, the sections of a template are exactly that-- a list of sub-templates
that make up the whole. You can compound as many of these lists as you want to create your abstracted template
from nothing but a list of filenames-- then let **Tater** sort it out!

If you need to visualize this concept, just think about all the templates and partials you used to create any
page in your last website. List them in order from top to bottom, add in some heirarchy rules, and there you go,
you've just made a list of all of your template's sections. It's as simple as that.
6 changes: 6 additions & 0 deletions examples/example2/treate/readme/readme_notice.txt
@@ -0,0 +1,6 @@
## You Should Also Know

That this `README` was generated by **Treate**. Try it:

`ruby examples/example2/run.rb readme`

6 changes: 6 additions & 0 deletions examples/example2/treate/readme/setup.rb
@@ -0,0 +1,6 @@
inherits 'treate/markdown'

def init
super
sections.insert_before('copyright', 'readme_notice')
end
3 changes: 0 additions & 3 deletions examples/example2/treate/setup.rb

This file was deleted.

3 changes: 0 additions & 3 deletions examples/example2/treate/textile/content/setup.rb

This file was deleted.

1 change: 0 additions & 1 deletion examples/example2/treate/textile/copyright.erb

This file was deleted.

1 change: 0 additions & 1 deletion examples/example2/treate/textile/header.erb

This file was deleted.

1 change: 0 additions & 1 deletion examples/example2/treate/textile/main.erb

This file was deleted.

0 comments on commit 2b03860

Please sign in to comment.