diff --git a/Data/Text/Template.hs b/Data/Text/Template.hs
--- a/Data/Text/Template.hs
+++ b/Data/Text/Template.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
 -- | A simple string substitution library that supports \"$\"-based
 -- substitution. Substitution uses the following rules:
 --
@@ -251,7 +253,11 @@
 takeWhile :: (Char -> Bool) -> Parser T.Text
 takeWhile p = do
     S s row col <- get
+#if MIN_VERSION_text(0,10,0)
+    case T.span p s of
+#else
     case T.spanBy p s of
+#endif
       (x, s') -> do
                   let xlines = T.lines x
                       row' = row + fromIntegral (length xlines - 1)
diff --git a/template.cabal b/template.cabal
--- a/template.cabal
+++ b/template.cabal
@@ -1,5 +1,5 @@
 name:                template
-version:             0.2.0.3
+version:             0.2.0.4
 description:
   Simple string substitution library that supports \"$\"-based
   substitution.  Meant to be used when Text.Printf or string
@@ -21,8 +21,9 @@
   build-depends:
     base >= 3.0 && < 4.4,
     mtl >= 1.1 && < 2.0.2,
-    text >= 0.7.2 && < 0.11
+    text >= 0.7.2 && < 0.12
 
+  extensions: CPP
   ghc-options: -funbox-strict-fields -Wall
   if impl(ghc >= 6.8)
     ghc-options: -fwarn-tabs
