Is Laravel’s Blade a programming language?

Asked

Viewed 443 times

9

After a brief discussion of why the HTML is not a programming language, characterize that not because it is not able to perform calculations, make decisions, change information contained in some type of memory, etc.

Blade is the language used by Laravel to build views. It contains the instructions started with a @, for example the @if, @section, @for, etc. It uses Laravel and PHP expressions to work.

Blade also has variables, but you don’t declare them directly on it. It gets the variables from the controller, and you can access with {{ }}.

This is an example of a Blade:

<div class="row">
    <div class="col">
        @if (isset($mensagem))
             <div class="alert alert-danger">{{ $mensagem }}</div>
        @else
             <div class="alert alert-primary">Tudo funcional.</div>
        @endif
    </div>
</div>

The above Blade was able to understand whether the variable $mensagem exists or not. Made a decision.

This makes the Laravel Blade a programming language?

  • 1

    One of the needs of a programming language is "change information contained in some type of memory;", if he only accesses the memory but does not change it, I believe it is not (narrowly). I am not an expert so I will leave the answers to those who understand

  • @Costamilam then, the fact that she reads, but does not create, confuses me a little. Although, with <?php $variavel = 123 ?> you declare, and soon you can read in Blade. But there you are already using PHP directly, but then Blade is also indirect PHP. I do not know.

  • You can place CSS inline in HTML tags or inside <style>, but it’s still separate languages. And like Woss said,, "PHP is a programming language or a superset of C?" just like Blade is PHP. It depends on your definition of what a programming language is

1 answer

7


I took a look over at documentation and as far as I can make out Turing complete, therefore it is a programming language, as well as any language of template well complete. What made me consider so is that it has state storage, ability to do some data manipulations and flow control.

Of course it should be a thin layer on top of PHP, but it still has "own life" even though it is a transpilation. And I will not consider that the fact that it can inject PHP in gives the total capacity because there is not get the result by own means but delegating to another language.

In the comments asked that it holds no value, but what is this in the documentation?

@for ($i = 0; $i < 10; $i++)

I put in the Github for future reference.

It’s creating a variable, storing value in it, changing that value and checking it. Unless there’s something wrong that I don’t know it allows you to do everything a computer machine needs.

  • That’s why I left someone else :) good answer

  • I just didn’t say it’s a good programming language :P :) HTML+CSS tb is a programming language if you consider both as one thing, but...

  • That part: capacidade de fazer algumas manipulações de dados? I didn’t get that right, you’re trying to say that the blade in a certain way is limited? (I would just like to understand) since the blade you can write code and with it do any manipulation.

  • I didn’t talk about limitation, I just don’t know all the capacity it has, but it has enough to be a programming language. But limited it must be on some level, everything is, nothing has unlimited power.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.