Steven's Blog

A Dream Land of Peace!

Mojolicious框架备忘

Will keep notes of some of the mojo tips I got.

1.A helper command to generate app for us.

1
mojo generate app

This will generate Mojolicious application directory structure.

1
mojo generate lite_app

This will generate Mojolicious::Lite application for us.

1
mojo generate lite_app hello

This will generate the app with the name “hello”

2.about deploying your app to heroku

1
2
3
4
5
cpanm Mojolicious::Command::deploy::heroku
mojo generate lite_app bigfan
./bigfan deploy heroku --create
or we can assign our app name like the following:
./bigfan deploy heroku -n bigfan

3.In mojo, something like “hello.html.ep”, here “ep” stands for “embedded perl”, we can have html.ep, json.ep, txt.ep.

4.Three kinds of placeholders.

generic placeholders:

1
2
3
get '/:fname/:lname' => sub{
	shift->render('capture);
};

relaxed placeholders:

1
2
3
get '/:fname/(.lname)' => sub{
	shift->render('capture);
};

wildcard placeholders:

1
2
3
get '/:fname/(*lname)' => sub{
	shift->render('capture);
};