Skip to content

Commit

Permalink
Mention tw2.core.DirLink in the docs. Fixes #69.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphbean committed Apr 16, 2013
1 parent 4aef579 commit dce1db6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/design.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ To define a resource, just add a :class:`tw2.core.Resource` subclass to the widg
.. autoclass:: tw2.core.CSSSource
.. autoclass:: tw2.core.JSLink
.. autoclass:: tw2.core.JSSource
.. autoclass:: tw2.core.DirLink

Resources are widgets, but follow a slightly different lifecycle. Resource subclasses are passed into the :attr:`resources` parameter. An instance is created for each request, but this is only done at the time of the parent Widget's :meth:`display` method. This gives widgets a chance to add dynamic resources in their :meth:`prepare` method.

Expand Down
9 changes: 9 additions & 0 deletions tw2/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ def __repr__(self):


class DirLink(Link):
''' A whole directory as a resource.
Unlike :class:`JSLink` and :class:`CSSLink`, this resource doesn't inject
anything on the page.. but it does register all resources under the
marked directory to be served by the middleware.
This is useful if you have a css file that pulls in a number of other
static resources like icons and images.
'''
link = Variable()
filename = Required
whole_dir = True
Expand Down

0 comments on commit dce1db6

Please sign in to comment.