Slovo::Plugin::DefaultHelpers - additional default helpers for Slovo
# local.xn--b1arjbl.xn--90ae # from http://local.слово.бг:3000 # or http://local.xn--b1arjbl.xn--90ae:3000 # in a template: <%= host_only %> #in a controller $c->host_only # local.слово.бг # from http://local.слово.бг:3000 # or http://local.xn--b1arjbl.xn--90ae:3000 # in a template: <%= ihost_only %> #in a controller $c->ihost_only <%= language%>
Slovo::Plugin::DefaultHelpers extends Mojolicious::Plugin::DefaultHelpers. It provides additional default helpers for Slovo. They are always loaded and ready for use. DefaultHelpers and TagHelpers are loaded unconditionally after all other mandatory for Slovo plugins.
The following additional helpers are provided.
Returns the host_only from $c->req->headers->host.
$c->req->headers->host
# local.xn--b1arjbl.xn--90ae # from http://local.слово.бг:3000 or http://local.xn--b1arjbl.xn--90ae:3000 # in a template: <%= host_only %> #in a controller $c->host_only
Returns the IDN (Internationalized Domain Name) from the current request.
# local.слово.бг # from http://local.слово.бг:3000 or http://local.xn--b1arjbl.xn--90ae:3000 # in a template: <%= ihost_only %> #in a controller $c->ihost_only
We replaced the implementation of this helper, provided otherwise by "is_user_authenticated" in Mojolicious::Plugin::Authentication. Now we check if the user is not guest instead of checking if we have a loaded user all over the place. This was needed because we wanted to always have a default user. See "before_dispatch". Now we have default user properties even if there is not a logged in user. This will be the guest user.
guest
Once again: Now this helper returns true if the current user is not Guest, false otherwise.
%# in a template Hello <%= $c->user->{first_name} %>, % if($c->is_user_authenticated) { You can go and <%= link_to manage => url_for('under_management')%> some pages. % else { You may want to <%=link_to 'sign in' => url_for('sign_in') %>. % }
Wrapper for $c->stash('ѩꙁыкъ'), which is set in $app->defaults in slovo.conf.
$c->stash('ѩꙁыкъ')
$app->defaults
slovo.conf
<%= language eq $ѩꙁыкъ %> <!-- renders 1 --> $c->language
The usual method is implemented.
Calls the parent's register if needed and registers additional helpers in Slovo application.
Mojolicious::Plugin::DefaultHelpers Slovo::Plugin::TagHelpers
To install Slovo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Slovo
CPAN shell
perl -MCPAN -e shell install Slovo
For more information on module installation, please visit the detailed CPAN module installation guide.