This reminds me, I had written a little tool to scan a directory recursively
for scala, xhtml and html files (intended to be run with <project
root>/src/main as its argument) and will search for uses of S.? and
<lift:loc> tags and print out all of the keys in a property file format so
that you can easily generate resource files for I18N. Would people be
interested in this? Should we maybe make a lift-utils module?

Derek

On Thu, Nov 27, 2008 at 7:17 AM, David Pollak <[EMAIL PROTECTED]
> wrote:

> Awesome
>
> On Nov 26, 2008 4:59 PM, "Jorge Ortiz" <[EMAIL PROTECTED]> wrote:
>
> Folks,
>
> One of the concerns raised at the Lift Workshop on Saturday was that
> ill-formed XML files in your templates will fail at run time instead of
> compile time, often with cryptic errors.
>
> To correct for this, I've added a simple test to lift-archetype-basic and
> lift-archetype-blank that will test all *.html and *.xml files in your
> src/main/webapp directory (and its subdirectories) to make sure they can all
> be loaded by Scala's XML parser. If they can't be loaded the test will fail
> and notify you which files couldn't be loaded and why.
>
> These tests run during Maven's 'test' phase. This phase is required before
> the 'package', 'install', or 'deploy' phases can run. Unfortunately, the
> 'jetty:run' phase only requires 'test-compile', not 'test'. If you want the
> test to run before starting Jetty, you'll have to specify it manually: 'mvn
> test jetty:run' (or 'mvn install jetty:run', etc).
>
> The test is available on any new projects created with Lift's archetypes.
> To add the test to your own project, the code is included below. It's a
> simple JUnit test. If you used a previous version of the archetypes to start
> your project, you can throw it into AppTest.scala
>
> Enjoy,
>
> --j
>
>
>   /**
>    * Tests to make sure the project's XML files are well-formed.
>    *
>    * Finds every *.html and *.xml file in src/main/webapp (and its
>    * subdirectories) and tests to make sure they are well-formed.
>    */
>   def testXml() = {
>     var failed: List[java.io.File] = Nil
>
>     def wellFormed(file: java.io.File) {
>       if (file.isDirectory)
>         for (f <- file.listFiles) wellFormed(f)
>
>       if (file.isFile && (file.getName.endsWith(".html") ||
> file.getName.endsWith(".xml"))) {
>         try {
>           scala.xml.XML.loadFile(file)
>         } catch {
>           case e: org.xml.sax.SAXParseException => failed = file :: failed
>         }
>       }
>     }
>
>     wellFormed(new java.io.File("src/main/webapp"))
>
>     val numFails = failed.size
>     if (numFails > 0) {
>       val fileStr = if (numFails == 1) "file" else "files"
>       val msg = "Malformed XML in " + numFails + " " + fileStr + ": " +
> failed.mkString(", ")
>       println(msg)
>       fail(msg)
>     }
>   }
>
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to