示例#1
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))
     # Call the real save.
     super(Post, self).save(*args, **kwargs)
示例#2
0
文件: inlines.py 项目: 2292amit/forum
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)
示例#3
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)
示例#4
0
def render_inlines(value):
    """
    Render inlines in a string by passing them through inline templates.

    Template Syntax::

        {{ object.text|render_inlines }}

    Inline Syntax (singular)::

        <inline type="<app_name>.<model_name>" id="<id>" class="pull-left" />

    Inline Syntax (plural)::

        <inline type="<app_name>.<model_name>" ids="<id>, <id>, <id>" />
        <inline type="<app_name>.<model_name>" count="<count>"
                [sort="<field>" filter="<filter>"] />

    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.

    ``filter`` is a comma separated list of QuerySet-like lookup parameters,
    with colons instead of the equal sign.
    """
    return inlines(value)
示例#5
0
def render_inlines(value):
    """
    Render inlines in a string by passing them through inline templates.

    Template Syntax::

        {{ object.text|render_inlines }}

    Inline Syntax (singular)::

        <inline type="<app_name>.<model_name>" id="<id>" class="pull-left" />

    Inline Syntax (plural)::

        <inline type="<app_name>.<model_name>" ids="<id>, <id>, <id>" />
        <inline type="<app_name>.<model_name>" count="<count>"
                [sort="<field>" filter="<filter>"] />

    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.

    ``filter`` is a comma separated list of QuerySet-like lookup parameters,
    with colons instead of the equal sign.
    """
    return inlines(value)
示例#6
0
文件: inlines.py 项目: 2292amit/forum
def extract_inlines(value):
    return inlines(value, True)
示例#7
0
def extract_inlines(value):
    return inlines(value, True)
示例#8
0
def clear_inlines(value):
    return inlines(value, clear_inlines=True)
示例#9
0
def extract_inlines(value):
    """ Extract the inlines from ``value``. """
    return inlines(value, True)
示例#10
0
def extract_inlines(value):
    """ Extract the inlines from ``value``. """
    return inlines(value, True)