【问题标题】:What are html templating alternatives for Django? [closed]Django 的 html 模板替代品是什么? [关闭]
【发布时间】:2011-06-29 06:06:17
【问题描述】:

请注意,我来自 Ruby 和 Node.js 世界,希望使用简洁而不一定复杂的东西。

使用 haml 会很棒,但不是必需的。

我在看 Jinja2,但它似乎是与标准模板大致相同的想法的更好实现,恕我直言,标准模板似乎有点过度设计。如果你认为不是这样,我也想听听这样的意见。

TIA

【问题讨论】:

  • 你不使用 Django 的动机是什么?
  • Django 的模板非常非常好。它们可以是“简洁的”。它们不能很复杂,因为模板中禁止了很多东西。真正的代码必须在视图函数中,而不是模板中。我认为 Django 的模板是完全的胜利。你为什么反对他们?
  • 你读过the docs吗?任何使简单的工作变得复杂的东西在某种程度上都会被破坏。
  • 嗯,这个问题是 7 年前提出的......当时已经回答了
  • 你可以看看 yawrap:pypi.org/project/yawrap 无模板的纯 Python 和可笑的快速 html 生成器。这是一个不错的选择。

标签: python html model-view-controller templates


【解决方案1】:

Templating in Python 列出了一堆。

【讨论】:

  • 呸,我忘了这是pythonic所有东西的主要wiki。谢谢!
  • @Wojciech:不客气。我花了 5 秒钟的时间在谷歌上找到答案 ;-)
【解决方案2】:

我认为你会找到最接近的东西是Brevé

HAML:

#profile
  .left.column
    #date= print_date
    #address= current_user.address
  .right.column
    #email= current_user.email
    #bio= current_user.bio

简洁

div ( id = 'profile' ) [
    div ( _class = 'left column' ) [
        div (id = "date") [ 
            today() # Assumes we have a function called `today` registered.
        ]
        div (id = "address") [ 
            current_user.address
        ]
    ]
    div ( _class = 'right column' ) [
        div (id = "email") [ 
            current_user.email
        ]
        div (id = "bio") [ 
            current_user.bio
        ]
    ]
]

Breve 还有一个工具,converts HTML to Breve code

【讨论】:

    猜你喜欢
    • 2012-09-07
    • 2013-04-14
    • 1970-01-01
    • 2010-12-05
    • 2021-12-02
    • 1970-01-01
    • 2010-12-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多