S
S
Sanes2014-05-20 11:29:37
CMS
Sanes, 2014-05-20 11:29:37

How to properly split an HTML template? On the example of Modx

The question arose about the standardization of the code and, in general, the rules of good form. Which is better to choose from 2 options?
Version 1

<!doctype html>
<html lang="en">
<head>


  
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    



  


</head>
<body>	
</body>
</html>


<meta charset="UTF-8">
<title>Document</title>

Version 2
<!doctype html>
<html lang="en">


  
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    



  


<body>	
</body>
</html>


<head>
<meta charset="UTF-8">
<title>Document</title>
</head>

I would be grateful for links on the rules of code design. While I use the rule that each chunk must be with closed tags.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
ilyautkin, 2014-06-04
@Sanes

In the first option, we can connect some extras inside one of all the templates. scripts and styles so that they only load on the right pages. So I'm for the first option.

S
Sergey, 2014-05-20
@begemot_sun

I once did this:
1. Divided the layout into chunks
{html_begin}

<html>
<head>
<!-- тут стандартные элементы для верстки, script, link и т.п.

{body_begin}
</head>
<body>
<!-- тут верстка хидера и т.п. стандартных элементов, всякие меюшки, еще какая логика -->

{body_end}
<!-- тут подключение script и т.п. -->
</body>
</html>

The result was this pattern:
{html_begin}
<!-- здесь вставляем нестандартные элементы, зависящие он конкретного шаблона
{body_begin}
{{content}}
{body_end}

Something like this.
PS For prescription of years {} {{ }} could confuse places.

I
Illan, 2014-05-20
@Illan

It is more obvious and more convenient to use the first option, at least I do it that way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question