Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Choose a Template system to use #61

Open
GoogleCodeExporter opened this issue Apr 18, 2015 · 4 comments
Open

Choose a Template system to use #61

GoogleCodeExporter opened this issue Apr 18, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

Update the template code (r407 and HEADER_TEMPLATE) to use string.Template (new 
in Python 2.4) instead the current %(keyword)s format.

http://docs.python.org/library/string.html#template-strings

Original issue reported on code.google.com by aureliojargas@gmail.com on 11 Nov 2010 at 12:18

@GoogleCodeExporter
Copy link
Author

As a first step, string.Template is a good choice.

But we're going to be serious in templates, we'll need some more flexibility, 
such as conditional blocks at least.

For example, a template for an HTML page. The STYLE tag is optional and must 
not appear if the user did not specified a stylesheet. So the template needed 
to be something like:

    <HTML>
    <HEAD>
    <META NAME="generator" CONTENT="http://txt2tags.org">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">

    %% if data.style: %%
    <LINK REL="stylesheet" TYPE="text/css" HREF="./include/kiwi/kiwi.css">
    %% endif %%

    </HEAD>
    <BODY>
    %%body
    </BODY>
    </HTML>

I *really* don't want to reinvent the wheel and code yet another template 
system into txt2tags. I want to use one that is already done and maintained by 
someone else. One that is light enough, but with some really basic smart 
features as conditional blocks.

Oh, and just to make it clear: templates are not meant to handle the BODY of 
the document. The body tags are better handled by our dear getTags().

Some links I've collected:
http://wiki.python.org/moin/Templating
http://stackoverflow.com/questions/98245/what-is-your-single-favorite-python-tem
plating-engine
http://stackoverflow.com/questions/612788/best-python-templating-library-to-faci
litate-code-generation

I do appreciate any input on that.

Original comment by aureliojargas@gmail.com on 21 Dec 2011 at 10:00

  • Changed title: Choose a Template system to use

@GoogleCodeExporter
Copy link
Author

See also the comments in r407

Original comment by aureliojargas@gmail.com on 21 Dec 2011 at 10:08

@GoogleCodeExporter
Copy link
Author

See also issue 74.

Original comment by aureliojargas@gmail.com on 21 Dec 2011 at 10:08

@GoogleCodeExporter
Copy link
Author

If we can get a template system like this, the doHeader() function won't be 
necessary for generating code anymore. It will just populate a dictionary that 
will be passed to the template system.

Original comment by aureliojargas@gmail.com on 21 Dec 2011 at 10:11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant