O
O
ouexazgj2017-12-17 22:01:27
PHP
ouexazgj, 2017-12-17 22:01:27

Proper storage of text with variables?

I am developing a text constructor.
The user works in a WYSIWYG analogue of Word, then saves the document. The HTML string is sent to the database and stored there. In our constructor there is such a function, something like "variables". The user can create such variables, and scatter them throughout the text. If you change a variable in one place, it changes throughout the text. What's the best way to store these things?
My option is this:

<h1>Какой то текст.</h1>

<p>Меня зовут {{3932}}.</p>

In this case, 3932 = Andrew, for example. How do you like this storage option? Or is there a prettier option?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Boris Korobkov, 2017-12-17
@BorisKorobkov

... and you get a Smarty-type bike.
Since you want to do everything yourself, then at least use the i18n mechanism of your framework. For example, for Yii2 it is www.yiiframework.com/doc-2.0/guide-tutorial-i18n.h...

R
Roman Mirilaczvili, 2017-12-18
@2ord

It's called a "template engine" or just a template engine. There are plenty of them on the net.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question