diff --git a/CHANGELOG.md b/CHANGELOG.md index 1de5cc9..d157599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # (MODX)EvolutionCMS.libraries.ddTools changelog +## Version 0.60 (2023-05-14) +* \+ `\ddTools::getTpl`: The new public method (see README). + + ## Version 0.59 (2023-03-30) * \+ `\ddTools::parseText`: In addition to accessing nested properties via placeholders like `'[+prop.subProp+]'`, you can get whole object as JSON via placeholders like `'[+prop+]'` (see README → Examples). @@ -557,5 +561,5 @@ * \+ The first release. - + \ No newline at end of file diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index b0cf06e..4118745 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -1,6 +1,10 @@ # (MODX)EvolutionCMS.libraries.ddTools changelog +## Версия 0.60 (2023-05-14) +* \+ `\ddTools::getTpl`: Новый публичный метод (см. README). + + ## Версия 0.59 (2023-03-30) * \+ `\ddTools::parseText`: Помимо доступа свойствам вложенных объектов через плейсхоледры вида `'[+prop.subProp+]'`, вы также можете получить весь объект в JSON через плейсхолдеры вида `'[+prop+]'` (см. README → Примеры). @@ -559,5 +563,5 @@ * \+ Первый релиз. - + \ No newline at end of file diff --git a/README.md b/README.md index a35a299..845469c 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,28 @@ All kinds of query parameters, hash, ports, etc. are not modified. * Valid values: `string` +### `\ddTools::getTpl($tpl = '')` + +The same as `$modx->getTpl` with some differences: +* This method always returns `string` regardless of the parameter type. For example, `$modx->getTpl(null)` returns `null`, this method returns `''`. +* The parameter is optional. `$modx->getTpl()` throws an error, this method jsut returns `''`. +* `$modx->getTpl('@CODE:')` returns `'@CODE:'`, this method returns `''`. + +* `$tpl` + * Desctription: Chunk name or inline template. + * Valid values: + * `stringChunkName` + * `string` — use inline templates starting with `@CODE:` + * Default value: `''` + + +#### Returns + +* `$result` + * Desctription: Required template. + * Valid values: `string` + + ### `\ddTools::parseText($params)` Replaces placeholders in a text with required values. @@ -835,7 +857,7 @@ It's convenient to override this method in child classes if items are not plain Simple abstract class with some small methods facilitating your work. It is convenient to inherit your classes from this. -You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.biz/modx/ddgetdocumentfield) code. +You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.ru/modx/ddgetdocumentfield) code. #### `\DDTools\Base\Base::setExistingProps($props)` @@ -906,7 +928,7 @@ The same as `\DDTools\Base\Base::toJSON()`. Simple trait for ancestors with some small methods facilitating your work. -You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.biz/modx/ddgetdocumentfield) code. +You can see an example of how it works in the [(MODX)EvolutionCMS.snippets.ddGetDocumentField](https://code.divandesign.ru/modx/ddgetdocumentfield) code. #### `\DDTools\Base\AncestorTrait::createChildInstance($params)` @@ -2201,10 +2223,10 @@ array( ## Links -* [Home page](https://code.divandesign.biz/modx/ddtools) +* [Home page](https://code.divandesign.ru/modx/ddtools) * [Telegram chat](https://t.me/dd_code) * [Packagist](https://packagist.org/packages/dd/evolutioncms-libraries-ddtools) * [GitHub](https://github.com/DivanDesign/EvolutionCMS.libraries.ddTools) - \ No newline at end of file + \ No newline at end of file diff --git a/composer.json b/composer.json index 0259a58..6896027 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dd/evolutioncms-libraries-ddtools", "type": "modxevo-library-ddtools", - "version": "0.59.0", + "version": "0.60.0", "description": "A library with various tools facilitating your work.", "keywords": [ "modx", @@ -9,23 +9,16 @@ "modx evolution", "ddtools" ], - "homepage": "https://code.divandesign.biz/modx/ddtools", + "homepage": "https://code.divandesign.ru/modx/ddtools", "authors": [ - { - "name": "DD Group", - "email": "code@DivanDesign.biz", - "homepage": "https://code.divandesign.biz", - "role": "Owner" - }, { "name": "Ilyas Ronef", "email": "ilyas@DivanDesign.ru", "homepage": "https://ronef.ru", - "role": "Developer" + "role": "Owner" }, { "name": "Alexey Davydov", - "email": "davalemic@DivanDesign.ru", "homepage": "https://github.com/davalemic", "role": "Developer" }, diff --git a/modx.ddtools.class.php b/modx.ddtools.class.php index d37cb47..2fd7482 100644 --- a/modx.ddtools.class.php +++ b/modx.ddtools.class.php @@ -1,11 +1,11 @@ getTpl('@CODE:') returns '@CODE:' O_o + if ( + substr( + $tpl, + 0, + 6 + ) == + '@CODE:' + ){ + $result = substr( + $tpl, + 6 + ); + }else{ + $result = self::$modx->getTpl($tpl); + } + } + + return $result; + } + /** * parseText * @version 1.7 (2023-03-29) @@ -2389,7 +2423,7 @@ public static function getDocumentChildrenTVarOutput( * @desc Adds a required JS-file into a required MODX inner list according to its version and name. The method is used to register the scripts, that has already been connected manually. * Be advised that the method does not add script code, but register its name and version to avoid future connections with $modx->regClientScript and $modx->regClientStartupScript, and the script code will be deleted if the script had been connected with $modx->regClientScript or $modx->regClientStartupScript. * - * @see ddRegJsCssLinks snippet (http://code.divandesign.biz/modx/ddregjscsslinks), предназначенный для «правильного» подключения js и css. Даже при «ручном» подключении сниппет регистрирует то, что подключил, используя данный метод. + * @see ddRegJsCssLinks snippet (http://code.divandesign.ru/modx/ddregjscsslinks), предназначенный для «правильного» подключения js и css. Даже при «ручном» подключении сниппет регистрирует то, что подключил, используя данный метод. * * @param $params {stdClass|arrayAssociative} — Parameters, the pass-by-name style is used. @required * @param $params->name {string} — Script name. @required