def code( *args, &blk )
  # check for optional hash for options
  opts = args.last.kind_of?(Hash) ? args.pop : {}
  
  name_plus_part = args.first   # check for optional filename
    
  if name_plus_part 
    name, part = name_plus_part.split( '#' ) # split off optional part/anchor 
    
    content = find_content_from( name, part ) 
    
    # add name and part to opts so engine can use paras too  
    opts[ :name ] = name  
    opts[ :part ] = part if part
    
    return format_code( content, opts )
  elsif blk # inline code via block?
    content = capture_erb(&blk)
    return if content.empty?

    concat_erb( format_code( content, opts ), blk.binding )
    return
  else
    msg = '*** warning: empty code directive; inline code or file para expected'
    puts msg 
    return wrap_markup( "<!-- #{msg} -->" )
  end
end
def code( *args, &blk )
  # check for optional hash for options
  opts = args.last.kind_of?(Hash) ? args.pop : {}
  
  name_plus_part = args.first   # check for optional filename
    
  if name_plus_part 
    name, part = name_plus_part.split( '#' ) # split off optional part/anchor 
    
    content = find_content_from( name, part ) 
    
    # add name and part to opts so engine can use paras too  
    opts[ :name ] = name  
    opts[ :part ] = part if part
    
    return format_code( content, opts )
  elsif blk # inline code via block?
    content = capture_erb(&blk)
    return if content.empty?

    concat_erb( format_code( content, opts ), blk.binding )
    return
  else
    msg = '*** warning: empty code directive; inline code or file para expected'
    puts msg 
    return wrap_markup( "<!-- #{msg} -->" )
  end
end
Usage example:
  <%= code 'code/file.rb#section', :lang => 'ruby', :class => 'small' %>
    or
  <% code :lang => 'ruby' do %>
    code goes here
  <% end %>