Comments (2)
That seems to be bug at the moment, it's missing an implementation in the Renderer.
For now, you'll have to subclass the Renderer and add a visit_RawTag
method. However, RawTag is, if I remember correctly, not used and just a leftover from when other classes inherited from it. This is not a good state of affairs, I'll have to change the API somewhat, removing raw tag and adding another method to add raw stuff.
In the meantime, maybe sublcassing a Renderer
and a NavigationItem
(see http://pythonhosted.org/flask-nav/advanced-topics.html#implementing-custom-renderers) is what you need?
from flask-nav.
FTR:
Trying to add a button on navbar (login from popup, taken from bootstrap examples):
from flask_bootstrap.nav import BootstrapRenderer
from dominate import tags
from dominate.util import raw
class BootstrapRawTagRenderer(BootstrapRenderer):
def visit_RawTag(self, node):
return tags.li(raw(node.content))
app = Flask(__name__)
register_renderer(app,'bootstrap_rawtag', BootstrapRawTagRenderer)
...
@nav.navigation()
def navbar():
return Navbar('My Project', View('About', 'about'), RawTag('<button type="button" id="loginButton" class="btn btn-primary" data-toggle="modal" data-target="#loginModal">Login</button>'))
In your templates:
{% block navbar %}
{{ nav.navbar.render(renderer='bootstrap_rawtag') }}
{% endblock %}
{% block content %}
...
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h5 class="modal-title" id="exampleModalLabel">Login</h5>
</div>
<div class="modal-body">
<form method="post" action='/login/' name="login_form">
<p><input type="text" class="span3" name="eid" id="email" placeholder="Email"></p>
<p><input type="password" class="span3" name="passwd" placeholder="Password"></p>
<p><button type="submit" class="btn btn-primary">Sign in</button>
<a href="#">Forget the password?</a>
</p>
</form>
</div>
<div class="modal-footer">
Do you want to register?
<a href="#" class="btn btn-primary">Register</a>
</div>
</div>
</div>
</div>
{% endblock %}
@mbr I understand that allow this dominate.util.raw()
is scary, but wrap everything from flask_nav
seems to big to not consider this RawTag.
Let me know if you consider to accept a PR related to that
from flask-nav.
Related Issues (20)
- Modifying navbar during routing request HOT 5
- Append items to navbar HOT 1
- "Motivating Example" in the documentation is broken
- Custom css HOT 1
- View.active is incorrect when extra arguments are passed to __init__ HOT 7
- Hide 'Login' button when user authorized HOT 7
- Problem with endpoints which have multiple routes
- navbar not fully rendered in the example HOT 1
- parameters "role", "icon" and "info" for elements
- How to chang class container-fluid to container?
- Insert form in navbar HOT 2
- README references a missing 'Label' class
- AttributeError on Python 3.10 HOT 3
- Blueprints + flask-nav (documentation issue) HOT 7
- Please provide doc example of dynamic navbar creation HOT 3
- How do I adjust the navbar height? HOT 2
- Inheriting `Renderer` breaks all named renderer calls HOT 1
- right nav menu HOT 1
- Is it necessary to add attribute βtargetβ to Link class? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-nav.