What you have is a slow version of an Embperl subroutine.  Use an actual 
Embperl subroutine instead.  Use Execute at most once to load it.

It's my understanding that generally, templates are done in 
Embperl::Object.  But when doing it that way, your template is stored in 
your base Embperl::Object file, as Embperl code, rather than having 
everything stored in a database.  Of course, that has the advantage that 
you don't need to pull 500+ rows from your database to generate your page.

-- 
Ed Grimm



From:   Donavon <d...@mycopanet.com>
To:     "embperl@perl.apache.org" <embperl@perl.apache.org>
Date:   08/25/2016 05:35 PM
Subject:        EMBPERL: Calling Execute() multiple time per a page.



I have a loop that is calling Execute() to load a EMBPERL page as a 
template.  This template sets up and contains a bootstrap modal and some 
javascript .  The page I'm using as a test calls the template at least 
500x.
This is really slowing down the loading of the page for the client.
Are there any suggestion for optimizing and / or speeding this up?
Thank You,
~Donavon
djler...@yahoo.com



[$ while ( ($ID) = $sth->fetchrow) $] 

                 [- 
                %opts              = ();
                $opts{ID}          = $ID;
                $opts{title}       = "Modal Title";
                $opts{footer}      = "Modal Footer";
                $opts{frameSrc}    = "file.epl";
                $opts{linkText}    = 'Click Me to Open Modal';
                                 Execute("template.epl", \%opts);  
                 -]

[$ endwhile $]



--- template.epl

[-
  (%param)     = %{$param[0]};
-]
<!-- trigger modal -->
<a  id          = "trigger_[+ $param{ID} +]"
    title       = "[+ $param{title} +]" 
    alt         = "[+ $param{title} +]" 
    style       = "cursor:pointer;"
    >
  [- $escmode = 0; -][+ $param{linkText} +][- $escmode = 1; -]
</a>
<script>
 
 
  $('#trigger_[+ $param{ID} +]').click(function(){
    var frameSrc = "[- $escmode = 0; -][+ $param{frameSrc} +][- $escmode = 
1; -]";
 
    $('#iframe_[+ $param{ID} +]').attr("src",frameSrc);
 
    $('#modal_[+ $param{ID} +]').modal({show:true})
  });

</script>


<!-- modal -->
<div class="modal fade pageWidth" id="modal_[+ $param{ID} +]" 
tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog pageWidth" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" 
aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">
          [+ $param{title} +]
        </h4>
      </div>
      <div class="modal-body">
        <iframe id="iframe_[+ $param{ID} +]" src="" frameborder="0" 
height="400" class="pageFull"></iframe>
      </div>
      <div class="modal-footer">
        [+ $param{footer} +] <button type="button" class="btn btn-default" 
data-dismiss="modal">Close</button>
      </div>
    </div>
  </div>
</div> 



Reply via email to