docs/templates.rst
.. _templates:
Templates
=========
Default Views
-------------
By default this gem will use it's own templates for rendering its views.
The views that this gem serves by default (if the features are enabled) are:
* Login Page
* Registration Page
* Forgot Password Page
* Change Password Page
* Email Verification Page
If you want to customize these pages, there are two strategies. You can install
our default templates and modify them
.. code-block:: ruby
rails generate stormpath:views
or you can supply your own.
Custom Views
------------
If you want to supply your own view for a given feature, you need to let us
know where it is. You do this by telling us the specific path to the file.
For example, if you had a folder named ``views`` in the root of your project,
you would declare it like this:
.. code-block:: yaml
web:
register:
view: 'sessions/new.html.erb' // My custom login view
View Variables
--------------
Our gem will provide these view variables to all templates that are
rendered:
+-----------------+-------------------------------------------------------------------+
| **Variable** | **Description** |
+-----------------+-------------------------------------------------------------------+
| current_account | The account object of the logged in user (undefined otherwise) |
+-----------------+-------------------------------------------------------------------+
| signed_in? | Boolean value which determines whether the user is signed in |
| | or not |
+-----------------+-------------------------------------------------------------------+
You can also use the values from the ``stormpath.yml`` configuration file generated by this gem.
For example, if you want to iterate over all the fields that the register form contains you would do this by accessing:
.. code-block:: ruby
Stormpath::Rails.config.web.register.form.fields
or if you just need to use a conditional statement:
.. code-block:: ruby
Stormpath::Rails.config.web.change_password.enabled
Response Variables
------------------
Our gem will provide these objects on the response object for all JSON requests.
========== ==========
Variable Description
========== ==========
account The account object of the logged in user (undefined otherwise)
========== ==========
.. code-block:: ruby
{
account: {
href: account.href,
username: account.username,
modifiedAt: account.modified_at,
status: account.status,
createdAt: account.created_at,
email: account.email,
middleName: account.middle_name,
surname: account.surname,
givenName: account.given_name,
fullName: account.full_name
}
}