dispatch/modules/content/render.py
def content_to_html(content, article_id):
    """Returns artilce/page content as HTML"""

    def render_node(html, node, index):
        """Renders node as HTML"""
        if node['type'] == 'paragraph':
            return html + '<p>%s</p>' % node['data']
        else:

            if node['type'] == 'ad':
                id = 'div-gpt-ad-1443288719995-' + str(10 + index) + '-' + str(article_id)
                dfp_type = 'Intra_Article_' + str(index + 1)
                size = 'banner'
                if node['data'] == 'mobile':
                    size = 'box'
                newString = '<div class="o-article-embed__advertisement"><div class="o-advertisement o-advertisment--banner o-advertisement--center"><div class="adslot" id="' + id + '" data-size="' + size + '" data-dfp="' + dfp_type + '"></div></div></div>'
                return html + '<div class="o-article-embed o-article-embed--advertisement">%s</div>\n' % newString
            try:
                if node['type'] == 'poll':
                    node['type'] = 'widget'
                    node['data']['data'] = node['data']

                return html + embeds.render(node['type'], node['data'])
            except EmbedException:
                return html

    html = ''
    index = 0
    for node in content:
        html = render_node(html, node, index)
        if (node['type'] == 'ad'):
            index += 1
    # return mark_safe(reduce(render_node, content, ''))
    return mark_safe(html)
def content_to_html(content, article_id):
    """Returns artilce/page content as HTML"""

    def render_node(html, node, index):
        """Renders node as HTML"""
        if node['type'] == 'paragraph':
            return html + '<p>%s</p>' % node['data']
        else:

            if node['type'] == 'ad':
                id = 'div-gpt-ad-1443288719995-' + str(10 + index) + '-' + str(article_id)
                dfp_type = 'Intra_Article_' + str(index + 1)
                size = 'banner'
                if node['data'] == 'mobile':
                    size = 'box'
                newString = '<div class="o-article-embed__advertisement"><div class="o-advertisement o-advertisment--banner o-advertisement--center"><div class="adslot" id="' + id + '" data-size="' + size + '" data-dfp="' + dfp_type + '"></div></div></div>'
                return html + '<div class="o-article-embed o-article-embed--advertisement">%s</div>\n' % newString
            try:
                if node['type'] == 'poll':
                    node['type'] = 'widget'
                    node['data']['data'] = node['data']

                return html + embeds.render(node['type'], node['data'])
            except EmbedException:
                return html

    html = ''
    index = 0
    for node in content:
        html = render_node(html, node, index)
        if (node['type'] == 'ad'):
            index += 1
    # return mark_safe(reduce(render_node, content, ''))
    return mark_safe(html)
Returns artilce/page content as HTML