English 中文(简体)
包括[封闭]的区块/遗产/延伸物的收益
原标题:Benefits of blocks/inheritance/extends over includes [closed]
Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 10 years ago.

因此,我建造了一条使用django的申请。 我认为,我的团队中有几个人认为,我应当使用我的模板,而不是遵循区块/延伸模式。 他们认为:

  • Inheritance is too much logic for future maintainers
  • Includes are much easier to follow
  • We shouldn t limit future maintenance to "django programmers"

我确实不珍视我的应用模板,因此我试图提出一些令人信服的理由(非詹戈使用者),说明为什么遗产确实是前进的道路。 我很想听到更多关于这一点的看法。

我提出的几个理由已经:

  • 更多国家。 确保只需要在一个地点界定碎块的html结构;从合成物中提取模板的风险要小得多

  • 保留属于模板、模板和观点的内容;例如:

    < entitled>{% 封面所有权 %}My 网站{% endblock %}</ entitled>

    vs

    < entitled>{> page title <> >lt;/ entitled>

    这使前端人对前端的控制有了更多的控制,而不必再深入到后端观点。

  • 前线守则者已经必须熟悉从基点/压倒性违约延伸的继承概念;考虑以下各点:

    .nav {
      color: blue;
    }
    
    .nav.active {
      color: purple;
    }
    

你们能够把好的理由 throw入其中吗?

最佳回答

利用继承使(至少是IMHO)更容易建立一个主基.html模板,并允许所有其他网页<代码>extends。 这使得所有排版/打字都放在同一个档案中,其余则简单地以标准化方式使用<代码>id和<代码>>>>>的标签。

最好记住,关于<代码>extends的论点。 (和include)可以是variable。 www.un.org/spanish/ga/president

{% extends base_template %}

<代码>底线_template由我们的主背景处理器确定。 这加上一个简单的行政植被,即改变<代码>session.base_template ,使我们的设计者能够制造多种布局,并在两者之间换成单点。 她非常热爱。

问题回答

暂无回答




相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签