Deploying Twig into OpenEMR using Symfony components


(Sherwin Gaddis) #1

I would like some clarification on using the bootstrap header in Twig.

In the Core\Header.php file, I found this note:

    * Inside of a twig template (Parameters same as before):
    * ```html
    * {{ includeAsset() }}
    * ``` 

I attempted to launch this into the twig template.

This produced an error.

    [15-Oct-2019 12:33:05 America/New_York] PHP Fatal error:  Uncaught Twig\Error\SyntaxError: Unknown "includeAsset" function. in C:\oerm_dev\www\dev\mindfulemr4\templates\financialreports\insurance\summaryinsurancepaid.html.twig:1
    Stack trace: #0 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\ExpressionParser.php(451): Twig\ExpressionParser->getFunctionNodeClass('includeAsset', 1)
    #1 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\ExpressionParser.php(235): Twig\ExpressionParser->getFunctionNode('includeAsset', 1)
    #2 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\ExpressionParser.php(175): Twig\ExpressionParser->parsePrimaryExpression()
    #3 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\ExpressionParser.php(70): Twig\ExpressionParser->getPrimary()
    #4 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\Parser.php(142): Twig\ExpressionParser->parseExpression()
    #5 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\Parser.php(98): Twig\Parser->subparse(NULL, false)
    #6 C:\oerm_dev\www\dev\mindfulemr4\vendor\twig\twig\src\Environment.php(563): Twig\ in C:\oerm_dev\www\dev\mindfulemr4\templates\financialreports\insurance\summaryinsurancepaid.html.twig on line 1

My question is how to use this asset tag to pull in the header?

@robert.down @mdsupport

(Sherwin Gaddis) #2

Still having issues with getting the header to display at runtime in the twig.
May have to hard code it and move on.

I decided to go a different route.

(Robert Down, BSN, RN) #3

You’re working on the latest branch? Twig was removed a while back but then put back in, I’d make sure you’re up to date

(Sherwin Gaddis) #4

Thanks for the reply but I am lost to your statement, “latest branch”. Could you explain?


At least once a week or before I make a PR I run these command

git fetch upstream
git pull upstream master
git push origin master

Initially I setup my branch using these commands.

git clone
cd openemr-1
git remote add upstream

This should have connected me to the main codebase.

Thanks for your patience with me.

(Stephen Waite) #5

hi @juggernautsei, think @robert.down wants to make sure that you created this branch recently as in after aug 24, Bringing Twig back in by robertdown · Pull Request #2629 · openemr/openemr · GitHub

(Sherwin Gaddis) #6

I did thoroughly check the code for twig. I update my repo as I said and I did a search for twig assets. That is what sent me down the rabbit hole to connect the two. As I am learning symfony, I am building a report. I know you got that.

I had to think about this a lot and I would respectfully suggest that the code you wrote in the globals be move to the core directory. I am not sure of the reasoning for continuing the dependency on the globals file unless there is some backwards compatibility that I am missing.

I know you have many years of experience with symfony and are a master developer. This feels like a child giving instructions to their parent.

My reasoning for asking to place it in the core is that we can allow the powerful program to be powerful. What you wrote in many lines can be done in a single line. (this part is in my observations which is limited to a beginners knowledge and a few classes on the program) This allows symfony to hand the dependence injection.

On second thought, we can keep both. Right?