Nxs page - xkp/Doc GitHub Wiki

##Overview

Excess provides several mechanisms to create web pages, all following the basic usage

##Usage


1- Declare the page in your application's definition file (xml):


<page id="<Your page name>" post="<true|false>"/>
HTTP Method

The http method is derived from the post parameter, which defaults to false meaning GET will be used.

Parameter resolution

Depending on the chosen http method the parameters will be resolved using the names provided in step 2.

Uploaded files

The exception to the above rule are uploaded files, which will only be available on post requests. To access such files you must access the post property, which at the moment follows the interface of the underlying implementation library (formidable)

var filename = post.files[0].name;

1.1- Rendering options

  • Plain HTML: provide a 'src' tag referencing a plain html file included in the project. You may then use AutoTemplates to provide dynamic content. You could also ignore step 2 and the plain html will be response'd to the client.

  • xs applications: provide an 'application' tag referencing a xs project. The compiler will build such project and use its ouptut as the 'src' option in plain HTML rendering. Autotemplating also behaves in the same way.

  • Routing: you may choose not to provide any html at all and let your page be used as a redirecting router, please review step 2.


2- Implement your page as a traditional xs event (xs):


on <Your page>.render( <Your page parameters> )
{
    //your dynamic content or redirection here
}
Redirection

Web pages can redirect the routing at any time; in fact, a page must not provide html content at all as long as all its paths redirect somewhere, the general syntax for redirection is:

return redirect(<Redirection options>);

2.1- Redirection options:

  • To page: To redirect to an existing page pass a 'page' argument, the page must be valid.

      return redirect(page = "<page>");
    
  • To smarty: For old fashioned templating, pass a 'tpl' argument referencing a valid tpl file in your project.

      return redirect(tpl = "<tpl file>", <tpl arguments>);
    
⚠️ **GitHub.com Fallback** ⚠️