Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Descibe the ASSIGNJS helper #369

Merged
merged 1 commit into from
Oct 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion sources/29-web2py-english/05.markmin
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,18 @@ attributes = {'_id':'123', '_class':'myclass'}

The following set of helpers:

``A``, ``B``, ``BEAUTIFY``, ``BODY``, ``BR``, ``CAT``, ``CENTER``, ``CODE``, ``COL``, ``COLGROUP``, ``DIV``, ``EM``, ``EMBED``, ``FIELDSET``, ``FORM``, ``H1``, ``H2``, ``H3``, ``H4``, ``H5``, ``H6``, ``HEAD``, ``HR``, ``HTML``, ``I``, ``IFRAME``, ``IMG``, ``INPUT``, ``LABEL``, ``LEGEND``, ``LI``, ``LINK``, ``MARKMIN``, ``MENU``, ``META``, ``OBJECT``, ``ON``, ``OL``, ``OPTGROUP``, ``OPTION``, ``P``, ``PRE``, ``SCRIPT``, ``SELECT``, ``SPAN``, ``STYLE``, ``TABLE``, ``TAG``, ``TBODY``, ``TD``, ``TEXTAREA``, ``TFOOT``, ``TH``, ``THEAD``, ``TITLE``, ``TR``, ``TT``, ``UL``, ``URL``, ``XHTML``, ``XML``, ``embed64``, ``xmlescape``
``A``, ``ASSIGNJS``, ``B``, ``BEAUTIFY``, ``BODY``, ``BR``,
``CAT``, ``CENTER``, ``CODE``, ``COL``, ``COLGROUP``, ``DIV``,
``EM``, ``EMBED``, ``FIELDSET``, ``FORM``,
``H1``, ``H2``, ``H3``, ``H4``, ``H5``, ``H6``, ``HEAD``,
``HR``, ``HTML``, ``I``, ``IFRAME``, ``IMG``, ``INPUT``,
``LABEL``, ``LEGEND``, ``LI``, ``LINK``,
``MARKMIN``, ``MENU``, ``META``, ``OBJECT``, ``ON``, ``OL``,
``OPTGROUP``, ``OPTION``, ``P``, ``PRE``,
``SCRIPT``, ``SELECT``, ``SPAN``, ``STYLE``,
``TABLE``, ``TAG``, ``TBODY``, ``TD``, ``TEXTAREA``, ``TFOOT``,
``TH``, ``THEAD``, ``TITLE``, ``TR``, ``TT``,
``UL``, ``URL``, ``XHTML``, ``XML``, ``embed64``, ``xmlescape``

can be used to build complex expressions that can then be serialized to XML``xml-w``:cite ``xml-o``:cite. For example:
``
Expand Down Expand Up @@ -440,6 +451,32 @@ and a click on the link causes the content to be loaded in the div. This is simi

These ajax features require jQuery and "static/js/web2py_ajax.js", which are automatically included by placing ``{{include 'web2py_ajax.html'}}`` in the layout head. "views/web2py_ajax.html" defines some variables based on ``request`` and includes all necessary js and css files.

#### ``ASSIGNJS``
``ASSIGNJS``:inxx

ASSIGNJS allows a server-side value to be used as a client-side
javascript value.

For instance, if in a controller you write

``
return dict(stra='abcd', obj=alist)
``:code

and in a view write

``
<script>
{{=ASSIGNJS(o=obj)}}
...
``:code

Then the javascript variable o will have the value passed in obj,
which is alist.

A further example is shown below under
[[Javascript In Views #Javascriptinviews]].


#### ``B``
``B``:inxx
Expand Down Expand Up @@ -1897,6 +1934,7 @@ we get:


``javascript``:inxx
[[Javascriptinviews]]
### Javascript in views

Helpers can be used within external code by placing it in a template and then including the template where needed. For example, if some javascript code is in a file "/views/my.js", then it can be included in a view file:
Expand Down