简体   繁体   English

在HTML项目中分离关注点的最佳实践

[英]Best practices for separating concerns in HTML projects

I'm an experienced Java developer just beginning to learn HTML. 我是一位经验丰富的Java开发人员,刚开始学习HTML。

I'm working on a project that uses Spring MVC as a back-end framework. 我正在开发一个使用Spring MVC作为后端框架的项目。 On the front-end, my index page has several rather complex elements, each involving 150+ lines of html. 在前端,我的索引页面包含几个相当复杂的元素,每个元素都包含150多行html。 As an OO-programmer at heart, I hate how long my index.html is, and my OO instincts are compelling me to split some/all of these elements off into their own html files, particularly given that there is a possibility that some of them can be reused on other pages. 作为一名面向对象的编程人员,我讨厌index.html多长时间,而且我的OO本能迫使我将其中的一些/全部元素分解为自己的html文件,尤其是考虑到某些可能性它们可以在其他页面上重复使用。 I've come across examples of HTML tags being embedded into one another, but I haven't found much discussion about whether or not doing so is in line with best practices. 我已经看到了将HTML标记相互嵌入的示例,但是关于这样做是否与最佳做法一致,我没有找到太多讨论。

What are the best practices when it comes to modularization code reuse and the separation of concerns in modern HTML web-applications? 当谈到模块化代码重用,并在现代HTML Web应用分离关注什么最好的做法?

I feel like some php would help out tons for you, and then you could just do a <?php include 'header.php'; ?> 我觉得有些PHP可以为您提供帮助,然后您可以做一个<?php include 'header.php'; ?> <?php include 'header.php'; ?> to build everything <?php include 'header.php'; ?>建立一切

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM