Changeset 2144 in main for trunk/docs


Ignore:
Timestamp:
03/11/13 15:33:00 (6 years ago)
Author:
pcosquer
Message:

docs: richtext

Location:
trunk/docs/en/devel
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/en/devel/richtext.rst

    r2143 r2144  
    2929++++++++++++++ 
    3030 
     31Two functions are available to render a text: 
    3132 
    32 Template tags 
    33 +++++++++++++++ 
     33 * :func:`plmapp.filters.richtext` 
     34 * :func:`plmapp.filters.plaintext` 
    3435 
     36The first one returns an HTML output, 
     37the second one returns a plain text output. 
     38The plain text output is stored and indexed by the search engine. 
     39 
     40Both functions take the text to render and the current object 
     41(usually a controller). The current object is required to 
     42render relative links (like links to the next/previous revisions). 
     43 
     44Template filters 
     45++++++++++++++++ 
     46 
     47Two template filters are available to render a text in a template: 
     48 
     49 * :func:`.richtext_filter` 
     50 * :func:`.plaintext_filter` 
     51 
     52Both filters take a text to render and the current object: 
     53 
     54.. code-block:: django 
     55 
     56    {% load plmapp_tags %} 
     57    ... 
     58    {{ text|richtext_filter:obj}}  
     59 
     60or 
     61 
     62.. code-block:: django 
     63 
     64    {% load plmapp_tags %} 
     65    ... 
     66    {{ text|plaintext_filter:obj}}  
    3567 
    3668Views, ajax 
     
    6193+++++++ 
    6294 
     95Creation and modification forms automatically convert 
     96textarea widget to the enhanced version as set 
     97by the :setting:`RICHTEXT_WIDGET_ClASS` settings. 
     98 
     99If you need to enhance a textarea, you can call  
     100:func:`.forms.enhance_fields` if the form was built from a model. 
     101Alternatively, you can enhance any form like this:: 
     102 
     103    from django.conf import settings 
     104    from openPLM.plmapp.utils.importing import import_dotted_path 
     105 
     106    def enhance_form(form_cls, field): 
     107        widget_class = getattr(settings, "RICHTEXT_WIDGET_CLASS", None) 
     108        if widget_class is not None: 
     109            cls = import_dotted_path(widget_class) 
     110            form_cls.base_fields[field].widget = cls() 
     111        return form_cls 
     112 
     113 
    63114Markdown syntax 
    64115================== 
Note: See TracChangeset for help on using the changeset viewer.