Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Fixed formatting of code examples; removed any last remnants of view …
Browse files Browse the repository at this point in the history
…templates.
  • Loading branch information
Joe Catera committed Oct 1, 2012
1 parent b5ece1a commit de93f81
Show file tree
Hide file tree
Showing 40 changed files with 748 additions and 458 deletions.
4 changes: 2 additions & 2 deletions docs/dev_guide/api_overview/mojito_action_context.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ you create an instance of the ``ActionContext`` class, which we will call ``ac``
client context. See the `ActionContext Class <../../api/classes/ActionContext.html>`_ for the methods available from ``ac``.

One of the most common methods used from an instance of the ``ActionContext`` class is ``done``, which lets you pass data from the controller to a view. In the example ``controller.server.js`` below,
the ``done`` method sends the ``data`` object to the ``index`` view template.
the ``done`` method sends the ``data`` object to the ``index`` template.

.. code-block:: javascript
Expand All @@ -36,7 +36,7 @@ the ``done`` method sends the ``data`` object to the ``index`` view template.
* provides access to the Mojito API.
*/
index: function(ac) {
var data = { "data":"data passed to the index view template" };
var data = { "data":"data passed to the index template" };
ac.done(data);
}
};
Expand Down
29 changes: 19 additions & 10 deletions docs/dev_guide/code_exs/adding_assets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ The following topics will be covered:
Implementation Notes
====================

Each application has an ``assets`` directory for placing global CSS files that can be accessed by all of your mojits. Each mojit has its own ``assets`` directory for local CSS files
that are only accessible by the mojit.
Each application has an ``assets`` directory for placing global CSS files that can be accessed by
all of your mojits. Each mojit has its own ``assets`` directory for local CSS files that are only
accessible by the mojit.

The global assets are located in the ``{app_dir}/assets`` directory as shown here:

Expand All @@ -35,7 +36,8 @@ The global assets are located in the ``{app_dir}/assets`` directory as shown her
|-- routes.json
|-- server.js

In the ``simple`` mojit below, you see the local ``assets`` directory for CSS files only available to the ``simple`` mojit:
In the ``simple`` mojit below, you see the local ``assets`` directory for CSS files only available
to the ``simple`` mojit:

::

Expand All @@ -50,7 +52,8 @@ In the ``simple`` mojit below, you see the local ``assets`` directory for CSS fi
|-- tests/
`-- views/

This code example only uses local CSS, so the ``simple.css`` file is placed in the ``assets`` directory under the ``simple`` mojit.
This code example only uses local CSS, so the ``simple.css`` file is placed in the ``assets``
directory under the ``simple`` mojit.

.. code-block:: css
Expand All @@ -64,15 +67,18 @@ This code example only uses local CSS, so the ``simple.css`` file is placed in t
}
.toolbar li { display:inline; }
The CSS files in the mojit ``assets`` directory can be accessed in the template using the following path syntax:
The CSS files in the mojit ``assets`` directory can be accessed in the template using the following
path syntax:

``/static/{mojit}/assets/{css_file}.css``

This code example uses the ``simple`` mojit and the ``simple.css`` asset. To access ``simple.css``, you would use the following path:
This code example uses the ``simple`` mojit and the ``simple.css`` asset. To access ``simple.css``,
you would use the following path:

``/static/simple/assets/simple.css``

The ``index.hb.html`` template below includes ``simple.css`` from the ``assets`` directory using the path above.
The ``index.hb.html`` template below includes ``simple.css`` from the ``assets`` directory using the
path above.

.. code-block:: html

Expand Down Expand Up @@ -101,12 +107,15 @@ The ``index.hb.html`` template below includes ``simple.css`` from the ``assets``
</body>
</html>

To access the global assets for the application, you use a similar syntax, replacing the mojit name with the application name. Thus, if the application name is ``simple_assets`` and ``simple.css``
To access the global assets for the application, you use a similar syntax, replacing the mojit name
with the application name. Thus, if the application name is ``simple_assets`` and ``simple.css``
is in ``simple_assets/assets/``, you would access ``simple.css`` with the following path:

``/static/simple_assets/assets/simple.css``

.. note:: For the purpose of simplifying this code example, the ``setColor`` function was hardcoded into the template. In your Mojito applications, you should avoid mixing the business and presentation logic of your application by hardcoding JavaScript into your template.
.. note:: For the purpose of simplifying this code example, the ``setColor`` function was hardcoded
into the template. In your Mojito applications, you should avoid mixing the business and
presentation logic of your application by hardcoding JavaScript into your template.

Setting Up this Example
=======================
Expand Down Expand Up @@ -253,7 +262,7 @@ Source Code
===========

- `Mojit Assets <http://github.com/yahoo/mojito/tree/master/examples/developer-guide/simple_assets/mojits/simple/assets/>`_
- `Index View Template <http://github.com/yahoo/mojito/tree/master/examples/developer-guide/simple_assets/mojits/simple/views/index.hb.html>`_
- `Index Template <http://github.com/yahoo/mojito/tree/master/examples/developer-guide/simple_assets/mojits/simple/views/index.hb.html>`_
- `Simple Assets Application <http://github.com/yahoo/mojito/tree/master/examples/developer-guide/simple_assets/>`_


16 changes: 9 additions & 7 deletions docs/dev_guide/code_exs/app_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ This example shows how to configure a mojit and the routing for your application
Implementation Notes
====================

The ``application.json`` file is used to specify the mojits that your application can use. The example ``application.json`` below specifies that the application use the mojit ``SimpleMojit``.
The ``application.json`` file is used to specify the mojits that your application can use. The
example ``application.json`` below specifies that the application use the mojit ``SimpleMojit``.

.. code-block:: javascript
Expand All @@ -29,7 +30,9 @@ The ``application.json`` file is used to specify the mojits that your applicatio
}
]
The routing configuration for Mojito applications is contained in ``routes.json``. In this example ``routes.json``, the Mojito server is told to call the ``index`` method in the controller when an HTTP GET is called on the root path.
The routing configuration for Mojito applications is contained in ``routes.json``. In this example
``routes.json``, the Mojito server is told to call the ``index`` method in the controller when an
HTTP GET is called on the root path.

.. code-block:: javascript
Expand All @@ -44,7 +47,8 @@ The routing configuration for Mojito applications is contained in ``routes.json`
}
]
The ``index`` method is a canned method in the controller when you create a mojit. To learn how to create templates that get data from the controller,
The ``index`` method is a canned method in the controller when you create a mojit. To learn how to
create templates that get data from the controller,
see `Creating a Simple View with Handlebars <simple_view_template.html>`_.

Setting Up this Example
Expand All @@ -55,13 +59,12 @@ To set up and run ``simple_config``:
#. Create your application.

``$ mojito create app simple_config``

#. Change to the application directory.
#. Create your mojit.

``$ mojito create mojit SimpleMojit``

#. To specify that your application use ``SimpleMojit``, replace the code in ``application.json`` with the following:
#. To specify that your application use ``SimpleMojit``, replace the code in ``application.json``
with the following:

.. code-block:: javascript
Expand Down Expand Up @@ -94,7 +97,6 @@ To set up and run ``simple_config``:
#. From the application directory, run the server.

``$ mojito start``

#. To view your application, go to the URL:

http://localhost:8666
Expand Down
Loading

0 comments on commit de93f81

Please sign in to comment.