D
D
dkrylov2017-04-11 21:08:05
css
dkrylov, 2017-04-11 21:08:05

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

3 answer(s)
M
Maxim Fedorov, 2017-04-12
@qonand

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.

M
Maxim Timofeev, 2017-04-12
@webinar

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']);

D
Dmitry, 2017-04-11
@slo_nik

Good evening.
How did you install fontawesome?
If you don't want to, don't use this syntax.
Include fontawesome like here and use it however you like, without extra classes.
What is the problem?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question