Skip to content

Root Serving and Globals (API Change)

Compare
Choose a tag to compare
@sintaxi sintaxi released this 17 Aug 19:54
· 419 commits to master since this release

important - there were changes to the globals object. skip to bottom for upgrade path.


Disposable web serving.

Harp now works as a great little disposable web server for serving assets in a hurry. To use simply run harp server in the root of any directory that you want served. You may also create a _harp.json file in the root of your project for addition configuration.

The framework style directory structure still functions as usual but now requires a harp.json file in the root directory. When a harp.json file (no underscore) is found, it tells the server to serve a public directory instead of the root.

How global objects now work.

You put your globals in harp.json file as you did before...

{
  "globals": {
    "title": "Sintaxi Blog"
  }
}

and now you can reference then as first class attributes in all your templates...

h1= title

Breakdown of our planned API breakage (marked tasks are completed):

  • make globals truely global
  • server default to serve root
  • make templates look up the tree for the nearest _layout.xxx
  • make layout overrides relative paths
  • replace EJS with handlebars

Upgrade Path

  • run sudo npm install -g harp and restart your server node server.
  • remove globals scope form all references to the global variables in your app. For example globals.name is now referenced as just name. And globals.public.data is referenced as public.data.
  • add a harp.json file to your project if you want to keep your current application running the same way.