Answer the question
In order to leave comments, you need to log in
Why does Yii2 use this syntax instead of plain CSS?
Hello dear programmers ;)
I'm learning Yii2. Connected FontAwesome, and wondered:
Why use this syntax:
In place:
And so and so it works fine.
Is there any difference other than aesthetics? FA::icon('home');
<i class="fa fa-home"></i>
Answer the question
In order to leave comments, you need to log in
Any helpers that generate html are usually implemented simply for convenience and to reduce the amount of html code. When using such helpers in page views, you won't see any advantage over pure html, but in widgets they can be quite useful because allow you to do quite flexible things when writing a minimum of code.
Yii2 does not use this syntax:
You have connected a third-party extension, apparently a helper that generates such html:
Whether to use it is up to you.
In general, such helpers, like template engines, allow you to avoid mixing php and html code.
If you look at how yii is written, then it is used in view html. There is more of it than php, so helpers seem to be useless. Although a matter of taste. But in widgets and other framework classes, you will not find a single line of html code. Only php and helpers.
Than the specific helper is convenient I do not know. Unless it adds dependencies, but considering that this is an icon font and it is on all pages, as a rule, I don’t see the point, because you can use the built-in helper:Html::tag('i','',['class'=>'fa fa-home']);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question