<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Tests/snippet.paml</filename>
    </added>
    <added>
      <filename>Tests/syntax-include-with_override.paml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
 == Pamela
 == Brings the pleasure back to HTML and XML !
 -- Author: S&#233;bastien Pierre &lt;sebastien@ivy.fr&gt;
--- Date:     02-Jul-2009
+-- Date:     03-Oct-2009
 -- Creation: 24-Aug-2007
 
 Introduction
@@ -339,7 +339,7 @@ Dive into Pamela
   You can also specify *replacement values* for variables declared in the included pamela
   file as '${VARIABLE}'. For instance:
 
-  &gt;   %include widget/datepicker (ID=mywidget,TITLE=&quot;Start date&quot;)
+  &gt;   %include widget/datepicker {ID=mywidget,TITLE=&quot;Start date&quot;}
 
   with 'widget/datepicker.paml' being something like:
 
@@ -349,6 +349,15 @@ Dive into Pamela
   this is an easy way to make generic '.paml' snippets that can be used as ''templates'' 
   for specific elements.
 
+  In case you want to add additional class attributes or specific attributes, you can
+  add (and override) the included elements attributes by doing:
+
+  &gt;   %include widget/datepicker +.Imported(date=2009-10-23)
+
+  in the above example, the 'widget/datepicker.paml' snippet will be included, the 
+  'Imported' class will be added to the element class attributes and a 'date' attribute
+  will be set with the value '2009-10-23'.
+
   7. Ideas about using Pamela
   ===========================
 </diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -8,12 +8,12 @@
 # License           :   Lesser GNU Public License
 # -----------------------------------------------------------------------------
 # Creation date     :   10-May-2007
-# Last mod.         :   01-Sep-2009
+# Last mod.         :   23-Oct-2009
 # -----------------------------------------------------------------------------
 
 import os, sys, re, string
 
-__version__ = &quot;0.5.1&quot;
+__version__ = &quot;0.5.2&quot;
 PAMELA_VERSION = __version__
 
 # -----------------------------------------------------------------------------
@@ -604,6 +604,7 @@ class Writer:
 		self._content   = []
 		self._nodeStack = []
 		self._document  = Element(&quot;document&quot;)
+		self._override  = None
 
 	def onDocumentEnd( self ):
 		return self._document
@@ -619,9 +620,37 @@ class Writer:
 		self._node().append(Text(text))
 
 	def onElementStart( self, name, attributes=None,isInline=False ):
+		# We extend the override if present
+		if self._override:
+			# FIXME: This would be much more elegant with an ordered key-value
+			# pair set
+			keys           = []
+			class_override = None
+			# We look for the 'class' attribute, if any
+			for item in self._override:
+				if item[0] == &quot;class&quot;: class_override = item
+				keys.append(item[0])
+			# We now add all the attributes not overridden
+			for key, value in attributes:
+				if key not in keys:
+					self._override.append([key,value])
+				# We merge the class attribute if present
+				elif key == &quot;class&quot;:
+					if class_override[1]:
+						class_override[1] += &quot; &quot; + value
+					else:
+						class_override[1] = value
+			attributes = self._override
 		element = Element(name,attributes=attributes,isInline=isInline)
+		# We clear the override
+		if self._override:
+			self._override = None
 		self._node().append(element)
 		self._pushStack(element)
+	
+	def overrideAttributesForNextElement( self, attributes ):
+		self._override = []
+		self._override.extend(attributes)
 
 	def onElementEnd( self ):
 		self._popStack()
@@ -768,16 +797,23 @@ class Parser:
 			path = is_include.group(2).strip()
 			subs = None
 			# If there is a paren, we extract the replacement
-			lparen = path.find(&quot;(&quot;)
+			lparen = path.find(&quot;{&quot;)
 			if lparen &gt;= 0:
 				subs    = {}
-				rparen  = path.rfind(&quot;)&quot;)
+				rparen  = path.rfind(&quot;}&quot;)
 				for replace in path[lparen+1:rparen].split(&quot;,&quot;):
 					name, value = replace.split(&quot;=&quot;,1)
 					value       = value.strip()
 					if value and value[0] in [&quot;'&quot;, '&quot;']: value = value[1:-1]
 					subs[name] = value
 				path = path[:lparen].strip()
+			# FIXME: The + will be swallowed if after paren
+			plus = path.find(&quot;+&quot;)
+			if plus &gt;= 0:
+				element = &quot;div&quot; + path[plus+1:]
+				path    = path[:plus].strip()
+				_, attributes, _, _ = self._parsePamelaElement(element)
+				self._writer.overrideAttributesForNextElement(attributes)
 			if path[0] in ['&quot;',&quot;'&quot;]:path = path[1:-1]
 			# Now we load the file
 			local_dir  = os.path.dirname(os.path.join(self.path()))
@@ -798,6 +834,7 @@ class Parser:
 				for l in f.readlines():
 					# FIXME: This does not work when I use tabs instead
 					p = int(indent/4)
+					# We do the substituion
 					if subs: l = string.Template(l).substitute(**subs)
 					self._parseLine(p * &quot;\t&quot; + l)
 				f.close()</diff>
      <filename>Sources/pamela/engine.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 &lt;html
 	&lt;body
-		%include &quot;tag-textarea&quot; (NAME=pouet,VALUE=asda)
+		%include &quot;tag-textarea&quot; {NAME=pouet,VALUE=asda}</diff>
      <filename>Tests/syntax-include-replace.paml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7698d39b83eb9ce94e35b88fdfd00e95fa4d455a</id>
    </parent>
  </parents>
  <author>
    <name>Sebastien Pierre</name>
    <email>sebastien@type-z.org</email>
  </author>
  <url>http://github.com/sebastien/pamela/commit/ac4135dede575ca61788f5592b7c23c4be843a04</url>
  <id>ac4135dede575ca61788f5592b7c23c4be843a04</id>
  <committed-date>2009-10-23T14:13:48-07:00</committed-date>
  <authored-date>2009-10-23T14:13:48-07:00</authored-date>
  <message>Added support for %include PATH +CLASS.CLASS(attr=val,...)</message>
  <tree>42aa23bbeea2e9ca0f1712ec5a81e1e3987d3909</tree>
  <committer>
    <name>Sebastien Pierre</name>
    <email>sebastien@type-z.org</email>
  </committer>
</commit>
