django.template.defaultfilters.striptags - python examples

Here are the examples of the python api django.template.defaultfilters.striptags taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

3 View Complete Implementation : models.py
Copyright GNU Affero General Public License v3.0
Author : freedomofpress
    @property
    def preview(self):
        """Returns the first sentence of the post, with HTML tags
        stripped, for use as a preview blurb."""
        body_text = striptags(' '.join([
            child.value.source for child in self.body
            if child.block_type == 'rich_text'
        ]))
        sentences = body_text.split('.')
        return '.'.join(sentences[:1]) + '.'

3 View Complete Implementation : forms.py
Copyright MIT License
Author : r26zhao
    def clean_content(self):
        """
        检查content字段是否为空
        """
        value = self.cleaned_data['content']
        if striptags(value).replace(' ', '').replace(' ', '') == '' and '<img' not in value:
            self.add_error('content', '兄dei,评论内容不能为空~')
        return value

3 View Complete Implementation : catalog.py
Copyright MIT License
Author : r26zhao
def catalog(string):
    pattern = re.compile(r'<h\d.*</h\d>')
    match = pattern.findall(string)
    html = ''
    for i in range(len(match)):
        if match[i].startswith('<h2'):
            if i == 0:
                html += '<li><a href="#{}">{}</a><ul>'.format(striptags(match[i]), striptags(match[i]))
            elif i == len(match) - 1:
                html += '</ul></li><li><a href="#{}">{}</a></li>'.format(striptags(match[i]), striptags(match[i]))
            else:
                html += '</ul></li><li><a href="#{}">{}</a><ul>'.format(striptags(match[i]), striptags(match[i]))
        if match[i].startswith('<h3'):
            html += '<li><a href="#{}">{}</a></li>'.format(striptags(match[i]), striptags(match[i]))
            if i == len(match) - 1:
                html += '</ul>'
    return html

0 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : BirkbeckCTP
    def item_satle(self, item):
        return striptags(item.satle)

0 View Complete Implementation : feeds.py
Copyright Apache License 2.0
Author : edisonlz
    def item_satle(self, notification):
        return striptags(notification.message)

0 View Complete Implementation : mixins.py
Copyright MIT License
Author : ic-labs
    def extract_text(self):
        # return the rendered content, with HTML tags stripped.
        html = render_content_items(
            request=None, items=self.contensatem_set.all())
        return striptags(html)

0 View Complete Implementation : test_striptags.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_strip(self):
        self.astertEqual(
            striptags('some <b>html</b> with <script>alert("You smell")</script> disallowed <img /> tags'),
            'some html with alert("You smell") disallowed  tags',
        )

0 View Complete Implementation : test_striptags.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_non_string_input(self):
        self.astertEqual(striptags(123), '123')

0 View Complete Implementation : test_striptags.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
    def test_strip_lazy_string(self):
        self.astertEqual(
            striptags(lazystr('some <b>html</b> with <script>alert("Hello")</script> disallowed <img /> tags')),
            'some html with alert("Hello") disallowed  tags',
        )

0 View Complete Implementation : forms.py
Copyright MIT License
Author : r26zhao
    def clean_content(self):
        value = self.cleaned_data['content']
        if striptags(value).replace(' ', '').replace(' ', '') == '' and not '<img' in value:
            self.add_error('content', '兄dei,评论内容不能为空~')
        return value