Syntax highlighting wordfile for Smarty files with individual brackets

Syntax highlighting wordfile for Smarty files with individual brackets

231
Basic UserBasic User
231

    Dec 12, 2019#1

    Hi Mofi,

    I have Smarty template files. Smarty is template engine with a mix of PHP & HTML content.
    I added the "TPL" extension to the PHP wordfile. The code highlighting is perfect. (Better than adding the "TPL" extension to the HTML wordfile). But the code folding with the PHP wordfile doesn't work like a charm.

    Here you can see a typical "details.tpl". The special in my case is, that we use "[{" and "}]" instead of the normal smarty brackets "{" and "}".

    Code: Select all

    [{$smarty.block.parent}]
    
    [{assign var="oConfig" value=$oView->getConfig()}]
    [{assign var="oBadges" value=$oDetails->getBadges()}]
    
    [{if $oViewConf->showInDetail() && $oBadges}]
        <div class="details-badges container">
            <div class="row">
                [{foreach key="oBadges" from=$oBadges->getArray() item="oBadge"}]
                     <p>[{$oBadge->getTitle()}]</p>
                [{/foreach}]
            </div>
        </div>
    [{/if}]
    What should I add to the PHP wordfile, so that the HTML commands and Smarty brackets are used for code folding?

    6,680583
    Grand MasterGrand Master
    6,680583

      Dec 13, 2019#2

      I suggest to copy %ProgramFiles%\IDM Computer Solutions\UltraEdit\wordfiles\php.uew to %APPDATA%\IDMComp\UltraEdit\wordfiles\php.uew and overwrite existing destination file already modified by you to restore original wordfile for PHP.

      Next download the attached ZIP file and extract the file smarty.uew into directory %APPDATA%\IDMComp\UltraEdit\wordfiles\ which contains php.uew and html.uew merged together and adapted for being a valid syntax highlighting definition.

      The color groups 1 to 10 are (nearly) the same as for PHP. There are some corrections (duplicates removed) and some adaptations for Smarty. For that reason I suggest to use the same color and font styles for these 10 color groups of language Smarty as for language PHP. Additional color groups in this wordfile are Alternate Block Comments for HTML block comments and the color groups C11 to C13 with HTML tags and HTML attributes and HTML entities.

      The HTML entities in color group 13 are defined case-sensitive in this wordfile although the language is declared as case-insensitive. For syntax highlighting it would be enough to have all HTML entities just in lower case in the wordfile. But the HTML entities are case-sensitive although HTML itself is case-insensitive.

      The code fold strings are defined in this wordfile as:

      Code: Select all

      /Open Fold Strings = "[{if" "[{foreach" "<div" "<ol" "<p" "<table" "<ul"
      /Close Fold Strings = "[{/if" "[{/foreach" "</div" "</ol" "</p" "</table" "</ul"
      More open and close fold strings can be added for code folding.
      smarty_version1.zip (50.22 KiB)   3
      Version 1 of syntax highlighting wordfile for Smarty
      Best regards from an UC/UE/UES for Windows user from Austria

      231
      Basic UserBasic User
      231

        Dec 14, 2019#3

        Hi Mofi, thanks for the magic :)

        It works, I added some code fold strings, and now everything is fine.

        Regards, Mario

        6,680583
        Grand MasterGrand Master
        6,680583

          Dec 14, 2019#4

          Hi Mario,

          I think, it would be good if you post the two lines with the fold strings used by you now if somebody else is interested in them. I will add them to the wordfile.

          I think, it would be also good to add more color groups. I have just seen the smarty wordfile on wordfiles page contributed by a user. Adding the color groups C3 to C8 to the wordfile created by me would make sense for completeness with cross-checking with the words of already existing color groups for PHP and HTML. I will perhaps look on further smarty wordfile improvements during the Christmas days.
          Best regards from an UC/UE/UES for Windows user from Austria