You can add your own filters to the liquid system much like you can add tags above. Filters are simply modules that export their methods to liquid. All methods will have to take at least one parameter which represents the input of the filter. The return value will be the output of the filter.
Advanced: you can access the site object through the @context.registers feature of liquid. Registers a hash where arbitrary context objects can be attached to. In Jekyll you can access the site object through registers. As an example, you can access the global configuration (_config.yml) like this: @context.registers[:site].config['cdn'].
moduleOctopressLiquidFiltersincludeOctopress::Date# Used on the blog index to split posts on the <!--more--> markerdefexcerpt(input)ifinput.index(/<!--\s*more\s*-->/i)input.split(/<!--\s*more\s*-->/i)[0]elseinputendend# Checks for excerpts (helpful for template conditionals)defhas_excerpt(input)input=~/<!--\s*more\s*-->/i?true:falseend# Summary is used on the Archive pages to return the first block of content from a post.defsummary(input)ifinput.index(/\n\n/)input.split(/\n\n/)[0]elseinputendend# Extracts raw content DIV from template, used for page description as # contains complete sub-template code on main page leveldefraw_content(input)/<div class="entry-content">(?<content>[\s\S]*?)<\/div>\s*<(footer|\/article)>/=~inputreturn(content.nil?)?input:contentend# Escapes CDATA sections in post contentdefcdata_escape(input)input.gsub(/<!\[CDATA\[/,'<![CDATA[').gsub(/\]\]>/,']]>')end# Replaces relative urls with full urlsdefexpand_urls(input,url='')url||='/'input.gsub/(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]*)/do$1+url+$3endend# Improved version of Liquid's truncate:# - Doesn't cut in the middle of a word.# - Uses typographically correct ellipsis (…) insted of '...'deftruncate(input,length)ifinput.length>length&&input[0..(length-1)]=~/(.+)\b.+$/im$1.strip+' …'elseinputendend# Improved version of Liquid's truncatewords:# - Uses typographically correct ellipsis (…) insted of '...'deftruncatewords(input,length)truncate=input.split(' ')iftruncate.length>lengthtruncate[0..length-1].join(' ').strip+' …'elseinputendend# Condenses multiple spaces and tabs into a single spacedefcondense_spaces(input)input.gsub(/\s{2,}/,' ')end# Removes trailing forward slash from a string for easily appending url segmentsdefstrip_slash(input)ifinput=~/(.+)\/$|^\/$/input=$1endinputend# Returns a url without the protocol (http://)defshorthand_url(input)input.gsub/(https?:\/\/)(\S+)/do$2endend# Returns a title cased string based on John Gruber's title case http://daringfireball.net/2008/08/title_case_updatedeftitlecase(input)input.titlecaseendendLiquid::Template.register_filterOctopressLiquidFilters