Why not use '.mako' as Mako template file extension?

715 views
Skip to first unread message
Message has been deleted

Bibby

unread,
Oct 17, 2008, 9:00:56 AM10/17/08
to web.py
webpy use '.html' as default template file extension, why not use
'.mako' ('.tmpl' or whatever) for Mako template engine? it's easy to
know what template engine it used.

Pradeep Kishore Gowda

unread,
Oct 17, 2008, 9:08:51 AM10/17/08
to we...@googlegroups.com

You can override the __getattr__ method of
web.contrib.template.render_mako to achieve that.

Pradeep Kishore Gowda

unread,
Oct 17, 2008, 9:13:23 AM10/17/08
to we...@googlegroups.com

See this: http://dpaste.com/85078/ .
I have used jinja because I already had a sandbox setup using it.

Bibby

unread,
Oct 17, 2008, 10:41:38 AM10/17/08
to web.py


On Oct 17, 9:08 pm, "Pradeep Kishore Gowda" <prad...@btbytes.com>
wrote:
> You can override the __getattr__ method of
> web.contrib.template.render_mako to achieve that.

Yes, i modified this method.
i mean why not use this extension as default?

Pradeep Kishore Gowda

unread,
Oct 17, 2008, 11:43:04 AM10/17/08
to we...@googlegroups.com
>Why not use

> '.mako' ('.tmpl' or whatever) for Mako template engine?

1. there is no such convention in mako, as far I know and I have used
mako since it's myghty days.
Also, if you see the frontpage of makotemplates.org, the example
uses ".html" . "

2. gives sensible defaults. In web.py, .html always means a template.
This is convention over configuration.
3. The IF-ELSE blocks just increases the amount of code in the base library.

+PG

On Fri, Oct 17, 2008 at 8:57 AM, Bibby <michae...@gmail.com> wrote:
>
> webpy use '.html' as default template file extension, hy not use


> '.mako' ('.tmpl' or whatever) for Mako template engine? it's easy to
> know what template engine it used.
>

> such as (web.contrib.template):
>
> ----<----
> class render_mako:
> ...skip...
> def __getattr__(self, name):
> # Assuming all templates are html
> #path = name + ".html"
> if os.path.exists(name + '.mako'):
> path = name + ".mako"
> elif os.path.exists(name + '.tmpl'):
> path = name + '.tmpl'
> else:
> path = name + '.html'
> t = self._lookup.get_template(path)
> return t.render
> ----<----
> >
>

--
Home - http://pradeepgowda.com
Heart - http://sampada.net
Yummy! - http://konkanirecipes.com

Bjorn Tipling

unread,
Oct 17, 2008, 6:29:32 PM10/17/08
to web.py
I don't use the web.py integration with mako, but I use mako
templates. I have vim configured to give me mako syntax highlighting
for .mako files.

On Oct 17, 8:43 am, "Pradeep Kishore Gowda" <prad...@btbytes.com>
wrote:

Bibby

unread,
Oct 18, 2008, 4:56:43 AM10/18/08
to web.py


On Oct 18, 6:29 am, Bjorn Tipling <bjorn.tipl...@gmail.com> wrote:
> I don't use the web.py integration with mako, but I use mako
> templates. I have vim configured to give me mako syntax highlighting
> for .mako files.

Hi, Bjorn.

Could you share your vim config about mako syntax highlighting?

Thanks. :)

Bjorn Tipling

unread,
Oct 18, 2008, 5:16:26 AM10/18/08
to web.py
It's not my vim config it's a syntax script available at
http://www.vim.org/scripts/script.php?script_id=1858

You then create a mako file in the .vim/ftdetect folder

:he ftdetect or http://vimdoc.sourceforge.net/htmldoc/filetype.html

Bibby

unread,
Oct 18, 2008, 5:59:42 AM10/18/08
to web.py


On Oct 18, 5:16 pm, Bjorn Tipling <bjorn.tipl...@gmail.com> wrote:
> It's not my vim config it's a syntax script available athttp://www.vim.org/scripts/script.php?script_id=1858
>
> You then create a mako file in the .vim/ftdetect folder
>
> :he ftdetect orhttp://vimdoc.sourceforge.net/htmldoc/filetype.html

Thanks, it works.

* Download mako.vim from http://www.vim.org/scripts/script.php?script_id=1858,
copy it to ~/.vim/syntax/.
* Then add this line in ~/.vimrc:

----<----
au BufRead,BufNewFile *.mako set filetype=mako
----<----
Reply all
Reply to author
Forward
0 new messages