Skip to content
Browse files

Add syntax highlighting to README.md

  • Loading branch information...
1 parent 6de838c commit 71b3754d13da040c525e1c7a56cc592714dde47f @edgurgel edgurgel committed May 17, 2013
Showing with 30 additions and 18 deletions.
  1. +30 −18 README.md
View
48 README.md
@@ -13,17 +13,21 @@ from other Erlang frameworks is that it is easy to set up and use.
After downloading and extracting, type
- make
- make app PROJECT=mynewproject
- cd ../mynewproject
- ./init-dev.sh
+```console
+make
+make app PROJECT=mynewproject
+cd ../mynewproject
+./init-dev.sh
+```
For Windows, type
-
- windows-make.bat
- windows-make.bat app PROJECT=mynewproject
- cd ..\mynewproject
- start-server.bat
+
+```console
+windows-make.bat
+windows-make.bat app PROJECT=mynewproject
+cd ..\mynewproject
+start-server.bat
+```
Then visit http://localhost:8001/ in your browser. Congratulations, you have
a web server. There will be a lot of PROGRESS REPORTs on your console but
@@ -96,20 +100,26 @@ for foreign keys, etc.).
an Erlang parameterized module on steroids. You instantiate a BossRecord like
a regular parameterized module:
- Article = article:new('id', "This is a title", "This is a body")
+```erlang
+Article = article:new('id', "This is a title", "This is a body")
+```
But then CB generates functions and attaches them to BossRecords, so you can
write code like
- {ok, SavedArticle} = Article:save()
+```erlang
+{ok, SavedArticle} = Article:save()
+```
Before saving to the database, the save() function will call a function called
validation_tests(), where you can perform custom validation logic.
CB also generates getter functions which can be invoked directly in templates,
so in your template you can write things like
- {{ article.title }}
+```erlang
+{{ article.title }}
+```
Speaking of which...
@@ -149,9 +159,9 @@ for storing and retrieving session information.
Rails (`/controller/action/id`). You can customize the routes and provide
a base URL in the priv/application.routes file. Of course, most routing occurs
with the pattern-matching controller logic, e.g.
-
- posts('GET', ["category", Category]) ->
- ...
+```erlang
+posts('GET', ["category", Category]) ->
+```
You can then generate URLs to match controller patterns in your templates like
so:
@@ -175,9 +185,11 @@ other language, Erlang gives you the benefits of asynchronous network
communcation without using callbacks. Here is a trivial example of a long-poll
controller:
- longpoll('GET', [Channel]) ->
- {ok, Timestamp, Messages} = boss_mq:pull(Channel, last),
- {json, [{timestamp, Timestamp}, {messages, Messages}]}.
+```erlang
+longpoll('GET', [Channel]) ->
+ {ok, Timestamp, Messages} = boss_mq:pull(Channel, last),
+ {json, [{timestamp, Timestamp}, {messages, Messages}]}.
+```
The call to `pull` blocks until a message is received. Because processes are
cheap in Erlang, the overhead of keeping alive a blocking request is very small

0 comments on commit 71b3754

Please sign in to comment.
Something went wrong with that request. Please try again.