Back to tutorials
  • 1Before We Start
  • 2Dependencies
  • 3Components
  • 4Configuring State
  • 5Rendering Data
  • 6Event Listeners
  • 7Updating State
  • 8Adding Todos
Metal.js HomeMetal.js
  • Documentation
Learn to create a simple Todo App with Metal.js and Soy

Dependencies

To follow along with this tutorial, you'll need Git and a recent version of Node.js/npm. You'll also need theJava Runtime Environment (JRE) installed to compile the .soy files.

Todo Boilerplate

Start by cloning the boilerplate repository:

git clone https://github.com/metal/metal-tutorial-todo.git

Then navigate to the root of the project in your terminal and install the local npm dependencies:

cd metal-tutorial-todo && npm install

The boilerplate that you'll build on is located in the src/soy directory. You can also view the finished product in the src/soy/final directory.

Building

To test drive the boilerplate located in the src/soy directory, run the build script shown below:

npm run build:soy

This runs babel + webpack to transpile and bundle the JavaScript into something consumable by web browsers.

This tutorial uses ES6 syntax; if you're unfamiliar with it, check outthis guide first.

To build the finished product, run the following script:

npm run build:soy:final

Demo

Now that you've built the project, go ahead and open the demo page located atdemos/index.html.

If you check the file you'll see that the component is already being invoked:

<script type="text/javascript">
    new metal.TodoApp();
</script>

When you invoke a component this way, it is rendered to the body element.

I installed the dependencies