Sitemap
Zainal Mustofa

Zainal Mustofa

Full Stack Ruby On Rails Developer

Meteor started

3 min readNov 4, 2015

--

For Developer Ruby On Rails i think we must learn meteor, why? I have interest article on here (Meteor Kill in Rails), just as a precaution if it could possibly :D

Oke now We must install meteor :

A. For OS X or Linux

curl https://install.meteor.com/ | sh

B. For Windows

https://install.meteor.com/windows

Creating first app

In this Totorial we will create a simple app to manage a todo list

meteor create simple-todos

This will create a new folder called `simple-todos` with all of the files a Meteor app needs:

simple-todos.js      # a JavaScript file loaded on both client and server simple-todos.html # an HTML file that defines view templates simple-todos.css   # a CSS file to define your app’s styles 
.meteor # internal Meteor files

Don’t forget run meteor on terminal and go to http://localhost:3000

Get Zainal Mustofa’s stories in your inbox

Join Medium for free to get updates from this writer.

Replace on simple-todos.html

<head><title>Todo List</title></head><body><div class="container"><header><h1>Todo List</h1></header><ul>{{#each tasks}}{{> task}}{{/each}}</ul></div></body><template name="task"><li>{{text}}</li></template>

Replace on simple-todos.js

if (Meteor.isClient) {// This code only runs on the clientTemplate.body.helpers({tasks: [{ text: "This is task one" },{ text: "This is task two" },{ text: "This is task three" }]});}

Open a browser and go to http://localhost:3000 the view will be look like this :

Todo List

conclusion

Meteor parses all of the HTML files in your app folder and identifies three top-level tags: <head>, <body>, and <template>.

head
body

Everything inside any <head> tags is added to the head section of the HTML sent to the client.

And everything inside <body> tags is added to the body section, just like in a regular HTML file.

If you see on <ul> tags meteor use spacebars compiler. Spacebars uses statements surrounded by double curly braces such as {{#each}} and {{#if}} to let you add logic and data to your views. You can pass data into templates from your JavaScript code by defining helpers. In the code above, we defined a helper called tasks on Template.body that returns an array. Inside the body tag of the HTML, we can use {{#each tasks}} to iterate over the array and insert a task template for each value. Inside the #each block, we can display the text property of each array item using {{text}}.

template

Everything inside <template> tags is compiled into Meteor templates, which can be included inside HTML with {{> templateName}} or referenced in your JavaScript with Template.templateName .

You can following tutorial on here

--

--

Zainal Mustofa
Zainal Mustofa

Written by Zainal Mustofa

Full Stack Ruby On Rails Developer