Using polymer with groovy pattern in Play 1 framework

I have simplified the code for the kernel. There is a custom <my-button> element:

<link rel="import" href="/public/bower_components/polymer/polymer.html">
<dom-module id="my-button">
    <template>
        <button onclick = "custom_click()">&{common.TWords.REGION_MAP}</button>
    </template>
    <script>
        Polymer({
            is: "my-button"
        });
    </script>
</dom-module>

      

and the index file where I am using my button:

 #{extends 'layouts/activ_page_template.html' /}
#{set title: play.i18n.Messages.get(common.TWords.ACTIVSITE_MENU_CONTACTS).concat(" | activ") /}
<script src="/public/javascripts/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/public/bower_components/webcomponentsjs/webcomponents.min.js"></script>

    <div class="row">
  <div class="col-xs-12">
    #{page_gradient_title}
        &{common.TWords.ACTIVSITE_TOPLINKS_CONTACTS}
    #{/page_gradient_title}
  </div>
</div>
//following two lines are in question
    #{polymer/my-button /}
    <my-button></my-button>

      

If I html import custom groovy tags the template elements used in light of the DOM like & {common.TWords.REGION_MAP} won't render, it will just be copied verbatim. But if I import the tag into groovy template like this # {polymer / my-button /}, it only works in Google Chrome. The problem is with other browsers like Mozilla firefox. In this browser, I get the "ReferenceError: Polymer not defined" error because the html import happens at the very end, naturally leaving the Polymer objects in the custom tags undefined. Is it possible to use groovy template inside the local DOM of a custom element if so?

+3


source to share


1 answer


I can't try it directly, but you can try the following steps:

  • MyButton should be a tag or better part of a dynamic html template (for example app/views/parts/polymerLibrary.html

    ) #include

    d in your page
  • each link in the tag <link rel="import" href="...">

    must be in Play Framework Groovy syntax, i.e.@{'/public/bower_components/polymer/polymer.html'}

  • most important : each import is called an absolute url with @@{'/public/bower_components/polymer/polymer.html'}

    (double notice @

    )


Try this and let us know if they work.

+1


source







All Articles