diff --git a/panels_ipe/panels_ipe.module b/panels_ipe/panels_ipe.module
index a305323..d3add3a 100644
--- a/panels_ipe/panels_ipe.module
+++ b/panels_ipe/panels_ipe.module
@@ -53,6 +53,11 @@ function panels_ipe_theme() {
     'panels_ipe_toolbar' => array(
       'variables' => array('buttons' => NULL),
     ),
+    'panels_ipe_portlet_wrapper' => array(
+      'variables' => array('output' => NULL, 'pane' => NULL, 'display' => NULL, 'renderer' => NULL),
+      'path' => drupal_get_path('module', 'panels_ipe') . '/templates',
+      'template' => 'panels-ipe-portlet-wrapper',
+    ),
   );
 }
 
@@ -211,3 +216,17 @@ function theme_panels_ipe_toolbar($vars) {
 
   return $output;
 }
+
+function template_preprocess_panels_ipe_portlet_wrapper(&$vars){
+  $pane = $vars['pane'];
+  $vars['id'] = '';
+
+  $vars['classes_array'][] = 'panels-ipe-portlet-marker';
+  if(!empty($pane->pid)){
+    $vars['id'] = 'id="panels-ipe-paneid-' . $pane->pid . '"';
+  }
+
+  if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
+    $vars['classes_array'][] = 'panels-ipe-nodrag';
+  }
+}
\ No newline at end of file
diff --git a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php
index ec171bd..a1dbe5b 100644
--- a/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php
+++ b/panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php
@@ -127,11 +127,7 @@ class panels_renderer_ipe extends panels_renderer_editor {
     // Hand it off to the plugin/theme for placing draggers/buttons
     $output = theme('panels_ipe_pane_wrapper', array('output' => $output, 'pane' => $pane, 'display' => $this->display, 'renderer' => $this));
 
-    if (!empty($pane->locks['type']) && $pane->locks['type'] == 'immovable') {
-      return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-nodrag panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>";
-    }
-
-    return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>";
+    return theme('panels_ipe_portlet_wrapper', array('output' => $output, 'pane' => $pane, 'display' => $this->display, 'renderer' => $this));
   }
 
   function render_pane_content(&$pane) {
diff --git a/panels_ipe/templates/panels-ipe-portlet-wrapper.tpl.php b/panels_ipe/templates/panels-ipe-portlet-wrapper.tpl.php
new file mode 100644
index 0000000..2fa1ffb
--- /dev/null
+++ b/panels_ipe/templates/panels-ipe-portlet-wrapper.tpl.php
@@ -0,0 +1,10 @@
+<?php
+/**
+ * @file panels-pane.tpl.php
+ * Portlet pane wrapper template
+ *
+ */
+?>
+<div class="<?php print $classes; ?>" <?php print $id; ?>>
+  <?php print $output; ?>
+</div>
\ No newline at end of file
