<h1>Project: <?=this.title?></h2>
<b>Todo:</b>
<ul>
<?hhp
for (i in 0...this.taskAmount) {
this.echo('<li>Task $i</li>');
}
?>
</ul>
var content : String = hhp.Hhp.render('todo.html', {
title : 'My cool project',
taskAmount : 10
});
@:hhp('todo.html')
class MyTemplate extends hhp.Template {
/** `taskAmount` will only accept integer values and have default value */
public var taskAmount : Int = 5;
/** `title` stays Dynamic because its type is not specified here */
}
class Main {
static public function main() {
var tpl = new MyTemplate();
tpl.taskAmount = 10;
tpl.| //code completion: title, taskAmount
var content : String = tpl.execute();
}
}
<!-- hello.tpl -->
Hello, <?=this.selectPerson()?>
<!-- bye.tpl -->
Goodbye, <?=this.selectPerson()?>
@:hhp('hello.tpl')class MikeHello extends hhp.Template { public function selectPerson() { return 'Mike'; }}
@:hhp('bye.tpl')class MikeBye extends MikeHello { }
@:hhp('hello.tpl')class BillHello extends hhp.Template { public function selectPerson() { return 'Bill'; }}
@:hhp('bye.tpl')class BillBye extends BillHello { }
class Main{ static public function main() { var tpl = new MikeHello(); trace(tpl.execute()); //Hello, Mike
var tpl = new MikeByte(); trace(tpl.execute()); //Bye, Mike
var tpl = new BillHello(); trace(tpl.execute()); //Hello, Bill
var tpl = new BillByte(); trace(tpl.execute()); //Bye, Bill }}
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Welcome to the club! ;)
This isn't any sort of criticism of your project, I'm just reflecting on my own journey as a coder. I had more experience with Actionscript 3 before I got more heavily into PHP, and I dislike how PHP often ends up being a complex mixture of HTML, CSS, JavaScript and PHP logic. Obviously good programming practises can avoid some of this, but even having to switch back and forth between HTML and PHP modes in a document takes a mental toll. The more abstracted approaches to templating (e.g. Ithril) are appealing to me more lately. It still looks like PHP is going to be a source of bread-and-butter for some time yet, but I keep searching for the "ultimate solution". :)
--
I don't think anybody's arguing here. Alexander has a fine tool and I agree it could be useful for a number of things.
My main point in my previous comment is that my ideal is reading a single language. I think both Ithril and Haxe-dom are good that way; I don't feel like they are "embedding" anything, but are rather "representing" the final output. There's no echoing of HTML strings, or "switching modes" within a document, which is what I would like to avoid.
--