Back to index

plone3  3.1.7
Functions
kss.core.pluginregistry._concatresource.compression.javascript Namespace Reference

Functions

def stripout_comments
def remove_markers
def compress

Detailed Description

\
The javascript compressor uses the 3rdparty packer module
that is taken from Plone's ResourceRegistries.

Function Documentation

Definition at line 26 of file javascript.py.

00026 
00027 def compress(data, compress_level):
00028     if compress_level == "devel":
00029         return remove_markers(data)
00030     elif compress_level == "stripped":
00031         return stripout_comments(data)
00032     elif compress_level == "safe":
00033         data = stripout_comments(data)
00034         jspacker_safe = JavascriptPacker('safe')
00035         return jspacker_safe.pack(data)
00036     elif compress_level == "full":
00037         data = stripout_comments(data)
00038         jspacker_full = JavascriptPacker('full')
00039         return jspacker_full.pack(data)
00040     elif compress_level == "safe-devel":
00041         date = remove_markers(data)
00042         jspacker_safe = JavascriptPacker('safe')
00043         return jspacker_safe.pack(data)
00044     elif compress_level == "full-devel":
00045         date = remove_markers(data)
00046         jspacker_full = JavascriptPacker('full')
00047         return jspacker_full.pack(data)
00048     else:
00049         # none
00050         return data

Here is the call graph for this function:

Definition at line 16 of file javascript.py.

00016 
00017 def remove_markers(data):
00018     'Replaces the ;;; markers by spaces but leaves the lines.'
00019     result = []
00020     for line in data.splitlines(True):
00021         if line.lstrip().startswith(';;;'):
00022             line = line.lstrip()[3:]
00023             result.append('   ')
00024         result.append(line)
00025     return ''.join(result)

Here is the caller graph for this function:

Definition at line 8 of file javascript.py.

00008 
00009 def stripout_comments(data):
00010     'Strips out ;;; lines from the data.'
00011     result = []
00012     for line in data.splitlines(True):
00013         if not line.lstrip().startswith(';;;'):
00014             result.append(line)
00015     return ''.join(result)

Here is the caller graph for this function: