Lucas_Werkmeister_WMDE added a comment.

  If I understand correctly, the templates are currently loaded by injecting 
them into the parser-cached HTML:
  
  name=LexemeView.php
        private function getLemmaVueTemplate() {
            return <<<HTML                                                      
                                                                                
                 
    <script id="lemma-widget-vue-template" type="x-template">                   
                                                                                
                 
        {$this->getRawLemmaVueTemplate()}                                       
                                                                                
                 
    </script>                                                                   
                                                                                
                 
    HTML;
        }
        private function getRawLemmaVueTemplate() {
            return <<<'HTML'                                                    
                                                                                
                 
    <div class="lemma-widget">                                                  
                                                                                
                 
        <ul v-if="!inEditMode" class="lemma-widget_lemma-list">                 
                                                                                
                 
    ...
        </div>                                                                  
                                                                                
                 
    </div>                                                                      
                                                                                
                 
    HTML;
        }
  
  I think this task can be split into two parts:
  
  1. Extract those templates into files, make the PHP code read them from 
there, and make the tests (QUnit or Jasmine – I think they both run in Node and 
have access to the file system) read them from those files as well. 
`getLemmaVueTemplate()` would still exist, but instead of calling 
`$this->getRawLemmaVueTemplate()`, it would call something to the effect of 
`file_get_contents()`. This would, I believe, //not// solve T197228 
<https://phabricator.wikimedia.org/T197228> yet, but it should be a useful 
first step, and already eliminate the duplicate templates in the test.
  2. Now that we have the templates in files, export them as ResourceLoader 
modules, and then make the JavaScript load them from there instead of from the 
`<script>` elements which the PHP code added to the parser-cached HTML. Later, 
remove the corresponding PHP code, so that we no longer embed the templates in 
the HTML. The QUnit and Jasmine tests can probably continue to load the 
templates directly from disk, and skip any ResourceLoader integration.

TASK DETAIL
  https://phabricator.wikimedia.org/T198455

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Rosalie_WMDE, Lucas_Werkmeister_WMDE
Cc: Lucas_Werkmeister_WMDE, noarave, Tarrow, Jakob_WMDE, Pablo-WMDE, Akuckartz, 
Iflorez, darthmon_wmde, alaa_wmde, DannyS712, Nandana, Lahi, Gq86, 
GoranSMilovanovic, Mahir256, QZanden, LawExplorer, _jensen, rosalieper, 
Scott_WUaS, Jonas, Izno, Wikidata-bugs, aude, Dinoguy1000, Lydia_Pintscher, 
Mbch331, Jay8g
_______________________________________________
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs

Reply via email to