Handle views in combo with Ace base templates
authorbep <bjorn.erik.pedersen@gmail.com>
Sun, 29 Mar 2015 19:12:13 +0000 (20:12 +0100)
committerbep <bjorn.erik.pedersen@gmail.com>
Sun, 29 Mar 2015 19:12:13 +0000 (21:12 +0200)
commitbe6696c34b1ac262eccb90ab8785128cc4065444
tree928628e2eb6f72f38313193802aeac1359d0c19f
parente8ca8602c003862fe3da87306c2b2c27918b29cc
Handle views in combo with Ace base templates

As views looks like a regular template, but doesn't need a base template, we have to look inside it.

Altough really not needed by this commit, reading the full file content into memory just to do a substring search is a waste.
So this commit implements a `ReaderContains` func that in most cases should be much faster than doing an `ioutil.ReadAll` and `bytes.Contains`:

```
benchmark                   old ns/op     new ns/op     delta
BenchmarkReaderContains     78452         20260         -74.18%

benchmark                   old allocs     new allocs     delta
BenchmarkReaderContains     46             20             -56.52%

benchmark                   old bytes     new bytes     delta
BenchmarkReaderContains     46496         1258          -97.29%
```

Fixes #999
helpers/general.go
helpers/general_test.go
helpers/path.go
tpl/template.go