forked from x4lldux/ashes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added channels and controllers to the readme
- Loading branch information
Nick Gartmann
committed
Jan 12, 2015
1 parent
3ca7ef8
commit 936ed76
Showing
1 changed file
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,60 @@ | ||
Ashes | ||
===== | ||
#Ashes | ||
|
||
A code generation tool for the [Phoenix](http://www.phoenixwebframework.com) web framework. | ||
|
||
###Controllers | ||
Generatse a controller with a given name, will also generate a view and create a folder | ||
for you to put related .eex templates in. **Don't forget to add the controller in `routes.ex`** | ||
|
||
```bash | ||
$ mix ashes.generate controller <controllername> | ||
``` | ||
|
||
```elixir | ||
# routes.ex | ||
defmodule MyApp.Router do | ||
resource "/my", MyController | ||
end | ||
``` | ||
|
||
Will give you the following methods by default: | ||
|
||
* index | ||
* edit | ||
* new | ||
* show | ||
* create | ||
* update | ||
* delete | ||
|
||
**Options** | ||
* `--skip-form` - removes the `edit` and `new` methods from the controller (likely used for APIs) | ||
* `--skip-view` - doesn't create a view module | ||
* `--skip-template`- doesn't create a folder for templates | ||
|
||
###Channels | ||
Generates a channel with the given name. | ||
|
||
```bash | ||
$ mix ashes.generate channel <channelname> [events] | ||
``` | ||
```elixir | ||
# routes.ex | ||
defmodule MyApp.Routes do | ||
socket "/ws", MyApp do | ||
channel "my:*", MyChannel | ||
end | ||
end | ||
``` | ||
|
||
Will give you the following methods by default: | ||
* `join(_topic, socket)` | ||
* `leave(_reason, socket)` | ||
|
||
If you provide events in the generate command, they will be added to the channel as | ||
```elixir | ||
def handle_in("eventname", message, socket) do | ||
{:ok, socket} | ||
end | ||
``` | ||
|