Задать вопрос

Тел: +7 965 3737 888

498

Просмотров

1

Ответов

YUI Loader as Django middleware

<p>This server-side middleware implements some of the functionality in the Yahoo
User Interface Loader component.  YUI JavaScript and CSS modules requirements
can be declared anywhere in the base, inherited or included templates, and the
resulting, optimized &lt;script&gt; and &lt;link rel="stylesheet"&gt; tags are inserted at
the specified position of the resulting page.</p>
<p>Requirements may be specified in multiple locations.  This is useful when zero
or more components are included in the HTML head section, and inherited and/or
included templates require possibly overlapping sets of YUI components in the
body across inherited and included templates.  All tags are collected in the
head section, and duplicate tags are automatically eliminated.</p>
<p>The middleware understands component dependencies and ensures that resources
are loaded in the right order.  It knows about built-in rollup files that ship
with YUI.  By automatically using rolled-up files, the number of HTTP requests
is reduced.</p>
<p>The default syntax looks like HTML comments.  Markup for the insertion point is
replaced with &lt;script&gt; and &lt;link&gt; tags:</p>
&lt;!-- YUI_init --&gt;

<p>Component requirements are indicated, possibly in multiple locations, with the
YUI_include markup.  It is removed from the resulting page by the
middleware. Example:</p>
&lt;!-- YUI_include fonts grids event dragdrop --&gt;

<p>Non-minified and compressed versions are requested, respectively, by:</p>
&lt;!-- YUI_version raw --&gt;
&lt;!-- YUI_version debug --&gt;

<p>Example:</p>
&lt;html&gt;&lt;head&gt;
&lt;!-- YUI_init --&gt;
&lt;!-- YUI_include dom event --&gt;
&lt;/head&gt;&lt;body&gt;
&lt;!-- YUI_include element selector reset fonts base --&gt;
&lt;/body&gt;&lt;/html&gt;

<p>Renders:</p>
&lt;html&gt;&lt;head&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.1/build/reset-fonts/reset-fonts.css" /&gt;
&lt;link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.5.1/build/base/base-min.css" /&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/yahoo-dom-event/yahoo-dom-event.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/element/element-beta-min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="http://yui.yahooapis.com/2.5.1/build/selector/selector-beta-min.js"&gt;&lt;/script&gt;
&lt;/head&gt;&lt;body&gt;
&lt;/body&gt;&lt;/html&gt;

<p>The markup format can be customized with global Django settings.  Example:</p>
YUI_INCLUDE_PREFIX_RE = r'{!'
YUI_INCLUDE_SUFFIX_RE = r'!}'

<p>would change markup to e.g. {! init !} and {! include dom event !}.</p>
<p>The base URL is customized with the YUI_INCLUDE_BASE setting, e.g.:</p>
YUI_INCLUDE_BASE = 'http://localhost:8000/yui/build/'

<p>To remove the XHTML trailing slash from the &lt;link&gt; tag, use:</p>
YUI_INCLUDE_CSS_TAG = '&lt;link rel="stylesheet" type="text/css" href="%s"&gt;'

<p>See also the <a href="http://trac.ambitone.com/ambidjangolib/wiki/YUI_include">home page for this module</a>.</p>

Вопрос полезен? Да0/Нет0
file_2387.py(16.2Кб)
None

Ответы (1):

Ответshadfc:29.08.2008
Ответ полезен? Да0/Нет0

This is really cool, but it doesnt seem to include any of the css dependencies on some of the controls such as autocomplete and calendar.

Hopefully someone can retool it to do this and updated it to YUI 2.5.2