예제 #1
0
def render_icon(icon, **kwargs):
    """Render a Bootstrap glyphicon icon."""
    attrs = {"class": add_css_class("glyphicon glyphicon-{icon}".format(icon=icon), kwargs.get("extra_classes", ""))}
    title = kwargs.get("title")
    if title:
        attrs["title"] = title
    return render_tag("span", attrs=attrs)
예제 #2
0
def render_icon(icon, title=""):
    """
    Render a Bootstrap glyphicon icon
    """
    attrs = {"class": "glyphicon glyphicon-{icon}".format(icon=icon)}
    if title:
        attrs["title"] = title
    return render_tag("span", attrs=attrs)
예제 #3
0
 def hidden_input(self):
     """ HTML for the hidden input element """
     return render_tag('input',
                       attrs={
                           'id': self.hidden_id,
                           'name': self.bound.html_name,
                           'type': 'hidden',
                           'value': self.bound.value() or ""
                       })
예제 #4
0
def render_icon(icon, title=''):
    """
    Render a Bootstrap glyphicon icon
    """
    attrs = {
        'class': 'glyphicon glyphicon-{icon}'.format(icon=icon),
    }
    if title:
        attrs['title'] = title
    return render_tag('span', attrs=attrs)
예제 #5
0
    def gen_hidden_div(self):
        """ Generate HTML code for the div that contains hidden tags """
        self.gen_full_js()

        content = self.js_script
        if not self.multiple and not self.gen_select:
            content += self.hidden_input()

        self.html += render_tag('div',
                                content=content,
                                attrs={'id': self.div2_id})
예제 #6
0
def comments_javascript():
    add_url = reverse('comments:add')
    javascript = """
    <script>
        window.COMMENTS_ADD_COMMENT_URL = '{}';
    </script>
    """.format(add_url)
    url = settings.STATIC_URL + 'js/comments.js'
    commentsjs = render_tag('script', attrs={'src': url})
    javascript = mark_safe(javascript + commentsjs)
    itemjstmpl = get_template('comments/_item_js.html').render({})
    javascript += itemjstmpl
    return javascript
예제 #7
0
def render_icon(icon, **kwargs):
    """
    Render a Bootstrap glyphicon icon
    """
    attrs = {
        "class": add_css_class(
            "glyphicon glyphicon-{icon}".format(icon=icon),
            kwargs.get("extra_classes", ""),
        )
    }
    title = kwargs.get("title")
    if title:
        attrs["title"] = title
    return render_tag("span", attrs=attrs)
예제 #8
0
def render_icon(icon, **kwargs):
    """
    Render a Bootstrap glyphicon icon
    """
    attrs = {
        'class': add_css_class(
            'glyphicon glyphicon-{icon}'.format(icon=icon),
            kwargs.get('extra_classes', ''),
        )
    }
    title = kwargs.get('title')
    if title:
        attrs['title'] = title
    return render_tag('span', attrs=attrs)
예제 #9
0
def render_icon(icon, **kwargs):
    """
    Render a Bootstrap glyphicon icon
    """
    attrs = {
        'class': add_css_class(
            'glyphicon glyphicon-{icon}'.format(icon=icon),
            kwargs.get('extra_classes', ''),
        )
    }
    title = kwargs.get('title')
    if title:
        attrs['title'] = title
    return render_tag('span', attrs=attrs)
예제 #10
0
def render_alert(content, alert_type=None, dismissable=True):
    """Render a Bootstrap alert."""
    button = ""
    if not alert_type:
        alert_type = "info"
    css_classes = ["alert", "alert-" + text_value(alert_type)]
    if dismissable:
        css_classes.append("alert-dismissable")
        button = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'
    button_placeholder = "__BUTTON__"
    return mark_safe(
        render_tag(
            "div", attrs={"class": " ".join(css_classes)}, content=button_placeholder + text_value(content)
        ).replace(button_placeholder, button)
    )
예제 #11
0
def render_alert(content, alert_type=None, dismissable=True):
    """
    Render a Bootstrap alert
    """
    button = ""
    if not alert_type:
        alert_type = "info"
    css_classes = ["alert", "alert-" + text_value(alert_type)]
    if dismissable:
        css_classes.append("alert-dismissable")
        button = '<button type="button" class="close" ' + 'data-dismiss="alert" aria-hidden="true">&times;</button>'
    button_placeholder = "__BUTTON__"
    return mark_safe(
        render_tag(
            "div", attrs={"class": " ".join(css_classes)}, content=button_placeholder + text_value(content)
        ).replace(button_placeholder, button)
    )
예제 #12
0
def render_alert(content, alert_type=None, dismissable=True):
    """
    Render a Bootstrap alert
    """
    button = ''
    if not alert_type:
        alert_type = 'info'
    css_classes = ['alert', 'alert-' + text_value(alert_type)]
    if dismissable:
        css_classes.append('alert-dismissable')
        button = '<button type="button" class="close" ' + \
                 'data-dismiss="alert" aria-hidden="true">&times;</button>'
    button_placeholder = '__BUTTON__'
    return mark_safe(render_tag(
        'div',
        attrs={'class': ' '.join(css_classes)},
        content=button_placeholder + text_value(content),
    ).replace(button_placeholder, button))
예제 #13
0
def render_alert(content, alert_type=None, dismissable=True):
    """
    Render a Bootstrap alert
    """
    button = ''
    if not alert_type:
        alert_type = 'info'
    css_classes = ['alert', 'alert-' + text_value(alert_type)]
    if dismissable:
        css_classes.append('alert-dismissable')
        button = '<button type="button" class="close" ' + \
                 'data-dismiss="alert" aria-hidden="true">&times;</button>'
    button_placeholder = '__BUTTON__'
    return mark_safe(render_tag(
        'div',
        attrs={'class': ' '.join(css_classes)},
        content=button_placeholder + text_value(content),
    ).replace(button_placeholder, button))
예제 #14
0
 def test_render_tag(self):
     self.assertEqual(render_tag("span"), "<span></span>")
     self.assertEqual(render_tag("span", content="foo"), "<span>foo</span>")
     self.assertEqual(render_tag("span", attrs={"bar": 123}, content="foo"),
                      '<span bar="123">foo</span>')
예제 #15
0
 def get_script(self):
     """ Insert the JS code inside a script tag """
     self.js_script = render_tag('script',
                                 content=mark_safe(self.js_script))