branaway / Japid

A Java-based statically-typed fast template engine that can be used in any Java code. It has special adapter for use with the Play! Framework.
113 stars 18 forks source link

Cannot extends template by template #6

Closed Syvius closed 13 years ago

Syvius commented 13 years ago

Hi, Bing.

I have a template named a.html: {#get 'css' /} As i know, it will be compiled as a abstract class with a abstract method css(). I want make a template b.html to extends a.html, like this: {#get 'css' /} {#get 'js' /} When i try to get it work, an error occurs: "The abstract method css in type a can only be defined by an abstract class." Then I look at the b.java. The class b is not abstract. Could you support a way to define class as abstract? Simple way like add a line to top `abstract. Thanks.

Syvius commented 13 years ago

I found a work around, write b.html as:

{set css}a#{/}.

{set js}b#{/}.

and use c to extends b, c.html:

{set css}c#{/}.

{set js}c#{/}.

:). But I also like japid to support extends abstract class by abstract class.

orefalo commented 13 years ago

hum, the formatting of your code is not picked up, please try adding 4 spaces in front of every line of CODE.

tks

branaway commented 13 years ago

Hi,

Multi-layer extension of the layout is not supported as you have noticed. Extending views are supported as you also have noticed. Japid makes no difference between views and tags, meaning any views can be used as tags, but layouts are compiled differently.

I'll consider your suggestion and see if I can come up with something clean.

Thanks for using Japid.

I'll

orefalo commented 13 years ago

Sorry, I mean in the comments.. above! ;-/

Syvius commented 13 years ago

In fact, write multi-layer extension in Japid is possible. I don't like put all layouts to _layout and put all tags to _tags. I want to organize them like this:

ControllerName
    -tags
        tag1.html
        tag2.html
    -layout
        layout1.html
        layout2.html
index.html (extends layout1)
somefunction.html (extends layout2)

It's easy to maintain. Japid is amazing. Now i can do it just don't use #{doLayout /}. Thanks Bing.

branaway commented 13 years ago

I just committed the change to implements the `abstract directive.

BTW, a few of my developers organize the tags the same way as you did. The new feature I have committed (partial path spec) allows one to reference tags and layouts in current view's sub-directory easier.