When using jade extends, is it ajax or does it pretend to be ajax?

0

For example, I render this view:

 html
  head
  body
   form(action="/buscar" method="POST")
    label(for="nombre") Nombre
    input(type="text" name="nombre")
    input(type="submit")
   block contenido
    h1 usuarios 

Then in another route this other view is loaded but as only a part of it changes, that is my question whether it is ajax or is it really loading everything

extends ./index.jade
block contenido
 for dato in datos
  li #{dato.nombre}
    
asked by Mauro Espinosa 26.07.2016 в 05:49
source

2 answers

3

You have a confusion of concepts. Jade is a library to write views in order to avoid the repetition of HTML (open and close tags) and force to give more order to the code (through tabulations).

To use it, it is processed at the server level and generates HTML code which is delivered to the client once processed.

Now extends is a Jade construction, through which you can extend a view (which works as a template) to reuse as much code as possible

As an example:

// vista layout.jade
doctype html
html
  head
    block title
      title Default title
  body
    block content

Here you define two block 's: One for the title ( title , with default value title Default title ) and another for the content ( content ).

Then, when extending from this view:

// vista article.jade
extends ./layout.jade
block title
  title Article Title

block content
  h1 My Article

you indicate that block title has content title Article Title and% block content content h1 My Article .

Thus, you have a single layout that is common for all possible views of your application / web and only modified in one place.

And finally, no, it's not AJAX, it's processing server-level file article.jade and delivering as HTML to the client.

I recommend reading the documentation

    
answered by 26.07.2016 в 11:02
1

It is loading everything, the extends in jade are very useful to include a content that is repeated on all pages. As for example the header or footer that is always repeated on all pages.

    
answered by 26.07.2016 в 10:29