コード例 #1
0
async def docs_patterns_home(req):
    tmpl = Template()
    tmpl.p + 'Coming soon.'

    return {
        'content': tmpl,
        'headline': Text('Common Patterns')
    }
コード例 #2
0
async def docs_patterns_abstraction(req):
    tmpl = Template()
    tmpl.p + 'Coming soon.'

    return {
        'content': tmpl,
        'headline': Text('Abstraction')
    }
コード例 #3
0
async def docs_patterns_reusability(req):
    tmpl = Template()
    tmpl.p + 'Coming soon.'

    return {
        'content': tmpl,
        'headline': Text('Reusability')
    }
コード例 #4
0
async def docs_integrations_home(req):
    tmpl = Template()
    tmpl.p + 'Coming soon.'

    return {'content': tmpl, 'headline': Text('Integrations')}
コード例 #5
0
async def docs_integrations_flask(req):
    tmpl = Template()
    tmpl.p + 'Coming soon.'

    return {'content': tmpl, 'headline': Text('Integrating with Flask')}
コード例 #6
0
ファイル: general.py プロジェクト: glennyonemitsu/funkybomb
async def home(req):
    followups = []
    followups.append({
        'header': 'It is easy to use',
        'content': (
            'Funky Bomb has a small set of rules to build out DOM-like '
            'structures and reusable templates with native Python.'
        ),
        'links': (
            ('Learn more:',),
            ('Syntax', '/docs/basics/syntax'),
            ('Templating', '/docs/basics/templating'),
            ('Utilities', '/docs/basics/utilities'),
        )
    })

    followups.append({
        'header': 'Use Python syntax and patterns',
        'content': (
            'Use normal programming patterns to build abstractions and '
            'construct more advanced HTML with the power of Python.'
        ),
        'links': (
            ('Common patterns:',),
            ('Abstraction', '/docs/patterns/abstraction'),
            ('Composition', '/docs/patterns/composition'),
            ('Reusability', '/docs/patterns/reusability'),
        )
    })

    followups.append({
        'header': 'Easy integration',
        'content': (
            'Any web framework that uses strings for serving HTML can have '
            'Funky Bomb integrated, since Funky Bomb outputs HTML strings '
            'itself.'
        ),
        'links': (
            ('Examples:',),
            ('Flask', '/docs/integrations/flask'),
        )
    })

    example_funky = show_python('''
    from funkybomb import render, Template
    from models import user_model

    tmpl = Template()
    table = tmpl.table

    for user in user_model.get_all():
        row = table.tr
        row.td + user.first_name
        row.td + user.last_name

    print(render(tmpl))
    ''')

    example_html = show_html('''
    <table>
        <tr>
            <td>John</td>
            <td>Doe</td>
        </tr>
        <tr>
            <td>Jane</td>
            <td>Doe</td>
        </tr>
    </table>
    ''')

    content = Template()

    pitch_python, pitch_html = row_cols(content, 6, 6)

    pitch_python.p(_class='h5') + 'Use Native Python'
    pitch_python + example_funky

    pitch_html.p(_class='h5') + 'Create HTML Pages'
    pitch_html + example_html

    fu = row_cols(content)

    fu.p(_class='lead mt-5 mb-5') + \
        'That is it! No other HTML template or code involved.'

    for item in followups:
        fu.p(_class='h4 mt-5') + item['header']
        fu.p + item['content']
        fu_links = fu.p

        for i, link in enumerate(item['links']):
            if i == 0:
                fu_links + (link[0] + ' ')
            else:
                fu_links.a(href=url(link[1])) + link[0]
                if i < (len(item['links']) - 1):
                    fu_links + ', '

    return {
        'content': content,
        'headline': Text('Funky Bomb')
    }