from flask import Blueprint, abort

from octopus.core import app
from octopus.lib import plugin

blueprint = Blueprint('fragments', __name__)

@blueprint.route("/<frag_id>")
def fragment(frag_id):
    cfg = app.config.get("FRAGMENTS", {}).get(frag_id)
    fname = cfg.get("function")
    if fname is not None:
        fn = plugin.load_function(fname)
        return fn()
    abort(404)

@@ -27,17 +27,34 @@
 t, abort
+, render_template
 %0A
-
 %0Afrom oc
@@ -262,16 +262,103 @@
 rag_id)%0A
+    if cfg is None:%0A        abort(404)%0A%0A    # see if we want to render from a function%0A
     fnam
@@ -448,16 +448,16 @@
 (fname)%0A
-
         
@@ -468,16 +468,158 @@
 rn fn()%0A
+%0A    # see if we want to render from a template%0A    temp = cfg.get(%22template%22)%0A    if temp is not None:%0A        return render_template(temp)%0A%0A
     abor

add fragments capability to render from template