Example #1
0
def render_inlines(value):
    """
    Renders inlines in a ``Post`` by passing them through inline templates.

    Template Syntax::

        {{ post.body|render_inlines|markdown:"safe" }}

    Inline Syntax (singular)::

        <inline type="<app_name>.<model_name>" id="<id>" class="med_left" />

    Inline Syntax (plural)::

        <inline type="<app_name>.<model_name>" ids="<id>, <id>, <id>" />

    An inline template will be used to render the inline. Templates will be
    locaed in the following maner:

        ``inlines/<app_name>_<model_name>.html``

    The template will be passed the following context:

        ``object``
            An object for the corresponding passed id.

    or

        ``object_list``
            A list of objects for the corresponding ids.

    It would be wise to anticipate both object_list and object unless
    you know for sure one or the other will only be present.
    """
    return inlines(value)
Example #2
0
def render_inlines(value):
    """
    Renders inlines in a ``Post`` by passing them through inline templates.

    Template Syntax::

        {{ post.body|render_inlines|markdown:"safe" }}

    Inline Syntax (singular)::

        <inline type="<app_name>.<model_name>" id="<id>" class="med_left" />

    Inline Syntax (plural)::

        <inline type="<app_name>.<model_name>" ids="<id>, <id>, <id>" />

    An inline template will be used to render the inline. Templates will be
    locaed in the following maner:

        ``inlines/<app_name>_<model_name>.html``

    The template will be passed the following context:

        ``object``
            An object for the corresponding passed id.

    or

        ``object_list``
            A list of objects for the corresponding ids.

    It would be wise to anticipate both object_list and object unless
    you know for sure one or the other will only be present.
    """
    return inlines(value)
Example #3
0
 def save(self, *args, **kwargs):
     # Inlines must be rendered before markup in order to properly preserve
     # whitespace
     self.body_rendered = inlines(self.body)
     self.tease_rendered = inlines(self.tease)
     # Render the markup and save it in the body_rendered field.
     self.body_rendered = mark_safe(formatter(self.body_rendered,
                                              filter_name=self.markup))
     self.tease_rendered = mark_safe(formatter(self.tease_rendered,
                                               filter_name=self.markup))
     # Run the body and tease through Smartypants, if enabled.
     if settings.BLOG_SMARTYPANTS:
         self.body_rendered = mark_safe(formatter(self.body_rendered,
                                                  filter_name='smartypants'))
         self.tease_rendered = mark_safe(formatter(self.tease_rendered,
                                                   filter_name='smartypants'))
     # Call the real save.
     super(Post, self).save(*args, **kwargs)
Example #4
0
def extract_inlines(value):
    return inlines(value, True)
Example #5
0
def extract_inlines(value):
    return inlines(value, True)
Example #6
0
 def save(self, force_insert=False, force_update=False):
     self.body_html = parser.inlines(self.body)
     self.body_html = markdown(self.body_html, output_format="html5")
     self.tease_html = markdown(self.tease, output_format="html5")
     super(Post, self).save(force_insert, force_update)