Eclipse template: User specific comment for new methods
Usefull for multiuser-projects!
Pattern:
// ${todo} ${user}: not yet implemented - ${enclosing_method} ${body_statement}
11380 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
// ${todo} ${user}: not yet implemented - ${enclosing_method} ${body_statement}
namespace :typos do task :rhtml do require 'erb' require 'active_support' require 'action_view' module TempTemplates; end Dir["./app/views/**/*.rhtml"].each do |fname| local_source = ERB.new(IO.read(fname), nil, '-').src template_source = "def _tmpl\n#{local_source}\nend" begin TempTemplates.module_eval(template_source, fname, 0 ) rescue Object => e t = ActionView::TemplateError.new("./app/views/", fname, {}, template_source, e) puts "TemplateError (#{t.message}) on line ##{t.line_number} of #{t.file_name}:\n"+t.source_extract + "\n------\n" end end end end
# Kick off django config machinery first from django.conf import settings settings.configure(TEMPLATE_DIRS=("/whatever/templates",)) import django.template import django.template.loader def render(name, *values): ctx = django.template.Context() for d in values: ctx.push() ctx.update(d) t = django.template.loader.get_template(name) return t.render(ctx) print render('layout.tmpl', dict(title='User'), dict(name='Bob', gender='M'))
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="styles.css" type="text/css" media="screen" /> <script type="text/javascript" src="common.js"></script> </head> <body> <div id="container"> <div id="header"> </div> <div id="wrapper"> <div id="main"> </div> </div> <div id="footer"> </div> </div> </body> </html>