realistschuckle/gohaml — pull request #5 by bmatsuo (2011-12-26 08:04:28+00:00)
Title: #4: Filters (CDATA, Javascript, CSS)

Patch for [issue #4](https://github.com/realistschuckle/gohaml/issues/4)

Implement [HAML filters](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#filters). Filters are special text transformation functions evaluated at parse-time. They allow for custom indentation (not alterable after parse-time).

A somewhat comprehensive set of tests is supplied for examples of functionality in specific cases.

There is a change to the way Engines are constructed. They require an additional indentation string to allow custom settings of filter output indentation. So changes to the command source file `hamlx.go` and the other test files were required. I would probably recommend a further change to the interface that turns configuring options into chain-able method calls. The API I am suggesting would function something like this

```go
eng := gohaml.NewEngine().Indent("\t").Parse("%p some HAML...")
```

An interface like this is more idiomatic Go, and more consistent with the Go package "template". Consistency is good =)

**important note:** There are some misc. differences that are the result of me habitually running `gofmt` on my source code. It is highly recommended in the Go community to keep repositories well formatted using the default options. This makes community-driven development much easier and cleaner in general. I did not run `gofmt` on all source files. I would recommend that *you* do that soon (**after merging this pull request**).

**important note 2:** Make sure to read http://help.github.com/send-pull-requests/ or search for some youtube tutorials if you're unfamiliar with excepting github pull-requests. I needed to read it pretty carefully =P