<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Jaggery - Delicious Javascript</title>
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <style type="text/css">
        body {
            padding-top: 60px;
        }
    </style>
    <link href="../css/prettify.css" rel="stylesheet">
    <!-- Le fav and touch icons -->
    <link rel="shortcut icon" href="../images/favicon.ico">
    <link rel="apple-touch-icon" href="../images/apple-touch-icon.png">
    <link rel="apple-touch-icon" sizes="72x72"
          href="../images/apple-touch-icon-72x72.png">
    <link rel="apple-touch-icon" sizes="114x114"
          href="../images/apple-touch-icon-114x114.png">
</head>

<body>

<%
include('/includes/topnavi.jag');
%>

<div class="container-fluid" style="width: 960px; margin: auto;">
    <div class="row">
        <div class="span16">
            <div class="page-header">
                <h1>
                    Documentation
                    <small>API documentation for Jaggery.js</small>
                </h1>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="span4">
            <div class="well">
<%
include('/includes/navi.jag');
%>
            </div>

        </div>
        <div class="span12">
            <div class="content" id="print" name="print">
                <h3>require()</h3>
                <br/>
<pre class="prettyprint linenums">
&lt;%
var core = require("core");
var log = new core.Log();
log.info("Required the module");

function myFunc() {
    var ws = require("ws");
    var client = new ws.WSRequest();
    log.info("Required within a function");
}
%&gt;
</pre>
<div id="pageLinks">
<a class="navilink" href="#overview">Overview</a>
<a class="navilink" href="#parameters">Parameters</a>
<a class="navilink" href="#returnVals">Return Values</a>
</div>

                <section id="overview">
                    <h4>Overview</h4>

                    <p class="description">In-built function <code>require()</code> allows to get a reference for any
                        available Jaggery module. Adding a Jaggery module is detailed <a href="modules.jag">here</a>.
                        
                        <br/><br/>
                        Apart from Jaggery modules, <code>require()</code> can import javascript files (or .json) and assign it to a variable / property
                        </p>

                    <pre class="prettyprint">var module = require("module_name");</pre>
                    <pre class="prettyprint">var foo = require("foo.js");</pre>
                </section>

                <section id="parameters">
                    <h4>Parameters</h4>
                    <table class="clsStd operations-table">
                        <tbody>
                        <tr>
                            <th>Parameter</th>
                            <th>Type</th>
                            <th>Description</th>
                        </tr>
                        <tr>
                            <td><code>module_name</code></td>
                            <td>String</td>
                            <td>
<pre class="prettyprint">
var module = require("module_name");
</pre>
                                The module name which is specified in the modules.xml
                            </td>
                        </tr>
                        <tr>
                            <td><code>{scriptname}.js</code></td>
                            <td>String</td>
                            <td>
<pre class="prettyprint">
var foo = require("foo.js");
</pre>
                                Name of the script that need to be imported
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </section>
                <section id="returnVals">
                    <h4>Return values</h4>
                    <table class="clsStd operations-table">
                        <tbody>
                        <tr>
                            <th>Value</th>
                            <th>Type</th>
                            <th>Description</th>
                        </tr>
                        <tr>
                            <td><code>module_name</code></td>
                            <td>Object</td>
                            <td>
<pre class="prettyprint">
var module = require("module_name");
</pre>
                                the Module as a javascript object
                            </td>
                        </tr>
                        <tr>
                            <td><code>{scriptname}.js</code></td>
                            <td>Object</td>
                            <td>
<pre class="prettyprint">
var foo = require("foo.js");
</pre>
                                The imported script as a javascript object
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </section>
            </div>
            <!-- /print div -->
            <br>
            <br>
        </div>

    </div>
<%
include('/includes/footerfunc.jag');
%>

</div>

<!-- /container -->
<%
include('/includes/scripts.jag')
%>

<script>
$(document).ready(function () {
    $('#require').toggleClass('active')
    $('#docs').addClass('active')
})
</script>
</body>
</html>
