NAME
Slovo::Plugin::DefaultHelpers – additional default helpers for Slovo
SYNOPSIS
# 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%>
DESCRIPTION
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.
HELPERS
The following additional helpers are provided.
host_only
Returns the host_only from $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
ihost_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
is_user_authenticated
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.
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') %>.
% }
language
Returns the current language from the request. For now we only return $c->config('default_language')
- 'bg-bg'. The extraction f the language from the current request is to be implemented
<%= language %>
$c->language
METHODS
The usual method is implemented.
register
Calls the parent's register if needed and registers additional helpers in Slovo application.
SEE ALSO
Mojolicious::Plugin::DefaultHelpers Slovo::Plugin::TagHelpers