realistschuckle / gohaml

An implementation of the popular XHTML Abstraction Markup Language using the Go language.
MIT License
95 stars 13 forks source link

Support for Method Calls #14

Open almond-neely opened 10 years ago

almond-neely commented 10 years ago

First of all, your gohaml project has made writing my go web app much easier(I hate HTML). Currently i've been using gohaml "statically"-- that is, only to replace html, and then html/template to plug in data/ iterate over ranges. My app has some pages with a lot of data from a DB, and i access this data on a per-page basis with a method call using html/template. For sanity/clarity's sake, i'm currently trying migrate all of my html/template code over to gohaml, but as far as i can tell, there's no support for method/function calls. Is this a feature we can expect in the future?

realistschuckle commented 10 years ago

@frostie5 Do you need method calls that take parameters?

brendensoares commented 10 years ago

Is there a way to call Go functions?

realistschuckle commented 10 years ago

Not at this time, no. I have plans to extend the gohaml library; however, I have had little time to dedicate to it. I plan on having it by the end of the year. I welcome contribs, if you feel like extending the language. To do so, add the correct constructs to the lang.y file and add a case in the resolveValue method on line 93 of tree.go. That should get methods in the works nicely.

(All of this advice comes from just reviewing the code. YMMV as you implement it.)

brendensoares commented 10 years ago

What is lang.y exactly?

realistschuckle commented 10 years ago

lang.y is the source code file in the repo: https://github.com/realistschuckle/gohaml/blob/master/lang.y

brendensoares commented 10 years ago

@realistschuckle right, but, more specifically, what is the y format?

realistschuckle commented 10 years ago

Sorry! Yacc. http://dinosaur.compilertools.net/yacc/

brendensoares commented 10 years ago

Thanks. I'll look into it :)