CoffeeScript
你可以在模板中撰寫 CoffeeScript,而且會被自動編譯。
如果你打算分離 CoffeeScript 檔案,Avane 有額外提供相關編譯功能,還敬請參考。
Avane
:coffee
class Point
x: 0
y: 0
constructor: (x, y) ->
@x = x
@y = y
add: (point) ->
new Point @x + point.x, @y + point.y
渲染結果
<script>
(function() {
var Point;
Point = (function() {
Point.prototype.x = 0;
Point.prototype.y = 0;
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.add = function(point) {
return new Point(this.x + point.x, this.y + point.y);
};
return Point;
})();
}).call(this);
</script>