Class t.w.w.w.ExpandMacro(Widget):

Part of twisted.web.woven.widgets View Source View In Hierarchy

A Macro expansion widget modeled after the METAL expander in ZPT/TAL/METAL. Usage:

In the Page that is being rendered, place the ExpandMacro widget on the node you want replaced with the Macro, and provide nodes tagged with fill-slot= attributes which will fill slots in the Macro:
   def wvfactory_myMacro(self, request, node, model):
       return ExpandMacro(
           model,
           macroFile="MyMacro.html",
           macroName="main")
   
   <div view="myMacro">
       <span fill-slot="greeting">Hello</span>
       <span fill-slot="greetee">World</span>
   </div>
Then, in your Macro template file ("MyMacro.html" in the above example) designate a node as the macro node, and nodes inside that as the slot nodes:
   <div macro="main">
       <h3><span slot="greeting" />, <span slot="greetee" />!</h3>
   </div>
Method __init__
Method generate Undocumented

Inherited from Widget:

Method _reset Undocumented
Method initialize Use this method instead of __init__ to initialize your Widget, so you
Method setSubmodel I use the submodel to know which attribute in self.model I am responsible for
Method getData I have a model; however since I am a widget I am only responsible
Method setData If the return value of getData is a Deferred, I am called
Method add Add `item' to the children of the resultant DOM Node of this widget.
Method appendChild Add `item' to the children of the resultant DOM Node of this widget.
Method insert Insert `item' at `index' in the children list of the resultant DOM Node
Method setNode Set a node for this widget to use instead of creating one programatically.
Method cleanNode Do your part, prevent infinite recursion!
Method _regenerate Undocumented
Method setDataCallback Undocumented
Method setUp Override this method to set up your Widget prior to generateDOM. This
Method generateDOM
Method modelChanged Undocumented
Method __setitem__ Convenience syntax for adding attributes to the resultant DOM Node of
Method __getitem__ Convenience syntax for getting an attribute from the resultant DOM Node
Method setError Convenience method for allowing a Controller to report an error to the
Method getTopModel Get a reference to this page's top model object.
Method getAllPatterns Get all nodes below this one which have a matching pattern attribute.
Method getPattern Get a named slot from the incoming template node. Returns a copy
Method addUpdateMethod Add a method to this widget that will be called when the widget
Method addEventHandler Add an event handler to this widget. eventName is a string
Method onEvent Dispatch a client-side event to an event handler that was
def __init__(self, model, macroTemplate='', macroFile='', macroFileDirectory='', macroName='', **kwargs): (source)
Parametersmodel(type: interfaces.IModel )
submodelsee Widget.setSubmodel (type: String )
setup(type: Callable )
def generate(self, request, node): (source)
Undocumented
API Documentation for twisted, generated by pydoctor.