What’s New

Map TemplateEngines by Extension

Previously you were able to define a single implementation of render.TemplateEngine per render.Engine . This has been removed in favor of a map of render.TemplateEngine .

Now you can map a file extension to a implementation of render.TemplateEngine . This means, not only, can you now use multiple template engines in one application, but you can also chain them together.

For example, if the file was foo.tmpl.html it would, by default, first be processed as a Go template, then that result would be sent to the Plush engine.

Here is a list of default implementations:

.html — processed as a Plush template, unchanged from previous releases.

— processed as a Plush template, unchanged from previous releases. .md — processed first as Markdown, then as a Plush template, unchanged from previous releases.

— processed first as Markdown, then as a Plush template, unchanged from previous releases. .tmpl — processed as a Go template.

— processed as a Go template. .js — processed as a Plush template.

New JavaScript Renderer

The render package has a new implementation of render.Renderer , JavaScript .

This means inside of an action you can do the following:

func HomeHandler(c buffalo.Context) error {

return c.Render(200, r.JavaScript("index.js"))

}

The render.Options type now has a new attribute, JavaScriptLayout . This new option is similar to the HTMLLayout option in that it will wrap *.js files inside of another *.js .

The new JavaScript renderer also has it’s own implementation of the partial function. This new implementation behaves almost the same as the original implementation, but is smart enough to know that if you are rendering an *.html file inside of a *.js file that it will need to be escaped properly, and so it does it for you.

$("#new-goal-form").replaceWith("<%= partial("goals/new.html") %>");

Rewritten Build Command

The original buffalo build command was written rather hastily almost a year ago and was a confusing mess of code that was the source of many bugs, as well as being difficult to fix and improve.

In v0.10.0 the entire buffalo build command was completely rewritten, cleaned up, improved, and a lot of bugs were squashed as a result.

This code is now easier to fix, test, improve, etc… So definitely a win, even if you don’t notice anything other than it being “quieter” (less output).

There are two new flags the accompany the buffalo build command now:

-d, --debug print debugging information

-k, --skip-assets skip running webpack and building assets

Improved Generators and Commands

Just like the buffalo build command most of the commands, and generators, have had their internals reworked to make them cleaner, easier to work with, and reduce bugs.

New Meta Package

The new github.com/gobuffalo/buffalo/meta package provides insight into Buffalo applications. This is useful for building commands, generators, plugins, etc…

m := meta.New(rootOfApp) # returns meta.App type App struct {

Pwd string `json:"pwd"`

Root string `json:"root"`

GoPath string `json:"go_path"`

Name Name `json:"name"`

Bin string `json:"bin"`

PackagePkg string `json:"package_path"`

ActionsPkg string `json:"actions_path"`

ModelsPkg string `json:"models_path"`

GriftsPkg string `json:"grifts_path"`

WithPop bool `json:"with_pop"`

WithDep bool `json:"with_dep"`

WithWebpack bool `json:"with_webpack"`

WithYarn bool `json:"with_yarn"`

WithDocker bool `json:"with_docker"`

WithGrifts bool `json:"with_grifts"`

}

New Addr Option

You can now decide what IP address Buffalo binds to when it is started. This is controlled by the new buffalo.Options.Addr attribute, as well as the ADDR ENV variable. By default, in development this is 127.0.0.1 and empty in other environments.

Webpack Improvements

The default Webpack configuration adds support for the CleanWebpackPlugin , as well as improves the configuration of the CopyWebpackPlugin .

The UglifyJSPlugin will now only be run during the buffalo build command, and not all the time.

These changes are only available to newly created projects, to get them in existing projects you must add the changes manually.

What’s Changed (i.e. Possible Breaking Changes)

App#Start Deprecated

The buffalo.App#Start method has been deprecated in favor of the buffalo.App#Serve method. The Start method will continue to work until v0.11.0 but you will receive deprecation warnings.

Automatic and Manual Removed

As noted in previous deprecation warnings the buffalo.Automatic and buffalo.Standard methods have been removed in favor of the buffalo.New method.

RegisterBinder Removed

As noted in previous deprecation warnings the buffalo.RegisterBinder function was removed in favor of binding.Register instead.

Middleware#CSRF Removed

As noted in previous deprecation warnings the github.com/gobuffalo/buffalo/middleware.CSRF middleware has been removed in favor of github.com/gobuffalo/buffalo/middleware/csrf.New .

TemplateEngine Option Removed

Previously you were able to define a single implementation of render.TemplateEngine per render.Engine . This has been removed in favor of a map of render.TemplateEngine . See above.

Tons of Bug Fixes

So many awesome bug fixes made into this release. Not just in Buffalo, but other projects, such as Plush, Inflect, Pop, Packr, and more…