How to Create a Blade

In order to create a blade, you first need to create an application and then create a bladeset (although we plan to make bladesets optional in the future).

There are two ways to create a blade

  • Via the Command Line Interface (CLI) or
  • Via the Web dashboard

We will go through both these ways below. Remember, you only need to follow one of the options as they both achieve the same thing.

Option 1. Creating a blade via the CLI

Once you have an application and a BladeSet you can create a Blade as follows:

$ ./brjs create-blade <app-name> <bladeset-name> <blade-name>

Example

The following command will create a Blade called input in the todo BladeSet which is part of the brjstodo app.

$ ./brjs create-blade brjstodo todo input

The input blade is represented on disk by a directory called input that resides under the directory called blades in the brjstodo app directory.

Option 2. Creating an app using the web dashboard

Start the BRJS development server by by entering the following on the command line:

./brjs serve

and navigate to http://localhost:7070. Click on the relevant app and select ‘Add blade’.

Example

This example follows on from those in How to Create an App and How to Create a Bladeset where we created an app called brjstodo and a bladeset called todo.

We are now going to create a blade called input within the todo bladeset.

Hover over the bladeset box to make the bladeset options visible. Two options will show “Add Blade” and “Run Tests”

Click on “Add Blade” to bring up the below window.

Enter the blade name ‘input’.

You will now see the name of the new blades displayed underneath the bladeset name.

Results

This creates a input directory within BRJS_HOME/brjs-apps/brjstodo/todo-bladeset/blades/ containing the following sub-directories:

  • src - for the JavaScript for the Blade
  • tests - for the blade tests
  • themes - for CSS and images
  • workbench - for the Workbench for the Blade we're developing
  • resources - for everything else

In future:

Where next?