What is the difference between buffered and unbuffered code?

This documentation is confusing.

It states that unbuffered code does not output any code directly. What does it mean?

But in general, what is the difference between buffered and unbuffered code?

It would be nice if they didn't disable copying and right click on the page!

+3


source to share


2 answers


Please ignore this answer as it is incorrect as pointed out in the comments

I invite you to take a look at the matte answer.




From what I understand in the documentation link you shared, I would say there is a big difference:




Unbuffered code is not executed when read, but deferred (it looks like javascript), which means the string is processed after processing.

They seem to map the string to an internal sub, which is a hybrid js + templating language.




Buffered code, on the other hand, is executed as javascript (it is preprocessed first to exit the html). Though it seems to have a different behavior according to which you entered the code.

For example, it is said that it is:

p='Test' + ' concatenation'

      

The result will be Test concatenation

But now you can do this:

p=(function() { return 'Does this really work ?! It seems so'; }())

      

This will result in Does this really work ?! It seems so

.

It just parses your code and escapes the html.

0


source


"Unbuffered" means that the code is executed, but the results are not sent to the output buffer.

Buffered also means that the code is executed and the results sent to the output buffer.

For example, this jade:



.unbuffered
  - 'unbuffered vs buffered'

.buffered
  = 'unbuffered vs buffered'

      

Produces this HTML:

<div class="unbuffered">
</div>
<div class="buffered">unbuffered vs buffered
</div>

      

+11


source







All Articles