What's new? | Help | Directory | Sign in
Google
                
How to join?
Project owners:
  laureano.arcanio, listas.condhor
Project members:
nom...@comcast.net

Lymon Project

A Humans friendly Web Development Toolkit

To get involve on this project you are invited to collaborate in our Google Groups mailing list at:

http://groups.google.com/group/lymon

Revision Count: 65


Lymon Test Coverage -r65

Lymon Templates Engine

The first low level component for Lymon is finished, actually this is a Fully capable and dynamic Templates Engine.

With this tool you can create a Dynamic version of any template you like, you just need to learn a simple Python syntax and you are ready to power your site with this useful engine.

The idea behind it is to provide Dynamic Templates, this mean that you can have a Main template and add different parts to it in different parts of the site on the fly.

This is accomplished using Documents Inheritance: You first define your Main template then you create a new document and add the new parts to it, then you can inherit the Main template structure to the new one, and all html tags will be inherited and mixed.

The goal of all this is to be able to have a Data Base driven template engine, where you can modify and create new templates online for your app, or add components to it.

The data base and components is in development for now, and i will be working hard to get this going.

Screen shot

In a Nutshell

You need TG2 and Toscawidgets to get it Working

Proceed with TG2 instalation as explained in:

http://turbogears.org/2.0/docs/main/DownloadInstall.html

Download an install lymon:

You need to install lymon package and the tw.lymon package

easy_install lymon
easy_install tw.lymon

In your controllers import lymon as:

from tw.lymon import LymonSite, template

create a controller method like:

@expose('tests.templates.index')
def index(self):
	pylons.c.site = LymonSite(document=template())
	return dict(page='index')

In the index.html add:

${tmpl_context.site()}

If everything goes well, you might see the Lymon Project page.

To add things to this page, you might inherit the template like:

from lymon.core import Document
new_template = Document()
new_template.h3(slot='content.left.title' id=False, html='This is my first Title !')
new_template.inherit(template)

( Follow instructions on how to use Documents in the follow section )

Lymon's Documents Syntax in a Nutshell

from lymon.core import Document

# This example shows how to create an HTML document
# Fisrt we add some Tags ( you can create any tag you like )

html = Document()
html.div(slot = 'site.header', html='Welcome !',attrs = {'class':'header'})
html.h6(slot = 'site.content.title', id = False, html='Write Your Name !',attrs = {'class':'title'})
html.input(slot = 'site.content.your_name', id = False, attrs = {'type':'text', 'name':'your_name'})
print html(render=True)
<div id="site" >
	<div class="header" id="header" >
		Welcome !
	</div>
	<div id="content" >
		<h6 class="title" >
			Write Your Name !
		</h6>
		<input type="text" name="your_name" >
			
		</input>
	</div>
</div>

# Inheritance mechanism on a new Document
# First we difine the new tags
# Then we call the inerit method with the parent Document as a parameter

new_html = Document()
new_html.span(slot = 'site.header.new', html = "I've been added to the firt Document !")
new_html.h1(slot = 'site.content.who', html = "Who are you dude ?", attrs={'class': 'no_class'})

new_html.inherit(html)
print new_html(render=True)

<div id="site" >
	<div class="header" id="header" >
		<span id="new" >
			I've been added to the firt Document !
		</span>
		Welcome !
	</div>
	<div id="content" >
		<h6 class="title" >
			Write Your Name !
		</h6>
		<input type="text" name="your_name" >
			
		</input>
		<h1 class="no_class" id="who" >
			Who are you dude ?
		</h1>
	</div>
</div>

By Laureano Arcanio