Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A good way of dealing with this is to associate your account_login_widget with its own view, like:</p> <pre><code>@view_config(name='login_widget', renderer='templates/account_login_widget.pt') def login_widget(request): return {'username': ...} </code></pre> <p>You should then be able to visit <a href="http://yourapp/login_widget" rel="noreferrer">http://yourapp/login_widget</a> and get back only the widget's HTML.</p> <p>What's left to do is to call the view and include the resulting HTML in your template. That is, instead of:</p> <pre><code>&lt;span metal:use-macro="load: account_login_widget.pt"&gt;&lt;/span&gt; </code></pre> <p>you'll want something like:</p> <pre><code>&lt;span tal:replace="structure render_view('login_widget')"&gt;&lt;/span&gt; </code></pre> <p><code>render_view</code> however doesn't exist in templates; you'll have to provide it yourself. It's best to use the Before Render Event for this: <a href="http://docs.pylonsproject.org/projects/pyramid/dev/narr/hooks.html#beforerender-event" rel="noreferrer">http://docs.pylonsproject.org/projects/pyramid/dev/narr/hooks.html#beforerender-event</a></p> <pre><code>from pyramid.events import subscriber from pyramid.events import BeforeRender from pyramid.view import render_view_to_response @subscriber(BeforeRender) def add_render_view_global(event): event['render_view'] = lambda name: render_view_to_response(context, request, name, secure).ubody </code></pre> <p>Done. This approach will also help should you ever need to (re)load widgets dynamically through AJAX.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload