skip to main content
10.1145/988672.988703acmconferencesArticle/Chapter ViewAbstractPublication PageswwwConference Proceedingsconference-collections
Article

Enforcing strict model-view separation in template engines

Published:17 May 2004Publication History

ABSTRACT

The mantra of every experienced web application developer is the same: thou shalt separate business logic from display. Ironically, almost all template engines allow violation of this separation principle, which is the very impetus for HTML template engine development. This situation is due mostly to a lack of formal definition of separation and fear that enforcing separation emasculates a template's power. I show that not only is strict separation a worthy design principle, but that we can enforce separation while providing a potent template engine. I demonstrate my StringTemplate engine, used to build jGuru.com and other commercial sites, at work solving some nontrivial generational tasks.My goal is to formalize the study of template engines, thus, providing a common nomenclature, a means of classifying template generational power, and a way to leverage interesting results from formal language theory. I classify three types of restricted templates analogous to Chomsky's type 1..3 grammar classes and formally define separation including the rules that embody separation.Because this paper provides a clear definition of model-view separation, template engine designers may no longer blindly claim enforcement of separation. Moreover, given theoretical arguments and empirical evidence, programmers no longer have an excuse to entangle model and view.

References

  1. N. Chomsky. Aspects of the Theory of Syntax. MIT Press, 1965.Google ScholarGoogle Scholar
  2. Enhydra. XMLC. http://xmlc.enhydra.org/project/aboutProject/index.html.Google ScholarGoogle Scholar
  3. FreeMarker. http://freemarker.sourceforge.net.Google ScholarGoogle Scholar
  4. B. Geer. Private communications.Google ScholarGoogle Scholar
  5. J. Hunter. The problems with JSP. http://www.servlets.com/soapbox/problems-jsp.html.Google ScholarGoogle Scholar
  6. JSP. http://java.sun.com/products/jsp.Google ScholarGoogle Scholar
  7. G. Kiczales, J. Lamping, A. Menhdhekar, C. Maeda, C. Lopes, J.-M. Loingtier, and J. Irwin. Aspect-oriented programming. In Proceedings European Conference on Object-Oriented Programming, volume 1241, pages 220--242. Springer-Verlag, 1997.Google ScholarGoogle ScholarCross RefCross Ref
  8. P. Kilpelainen and D. Wood. SGML and XML document grammars and exceptions. Information and Computation, 169(2):230--251, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. G. Krasner and S. Pope. A description of the model-view-controller user interface paradigm in the smalltalk-80 system. Journal of Object Oriented Programming, 1(3):26--49, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Macromedia. Coldfusion. http://www.macromedia.com/software/coldfusion.Google ScholarGoogle Scholar
  11. D. R. Milton and C. N. Fischer. LL(k) parsing for attributed grammars. In International Conference on Automata, Languages, and Programming, pages 422--430, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Separating C from V in MVC. http://mathforum.org/epigone/modperl/jilgygland, 2002.Google ScholarGoogle Scholar
  13. T. Parr. StringTemplate documentation. http://www.antlr.org/stringtemplate/index.tml, September 2003.Google ScholarGoogle Scholar
  14. T. J. Parr and R. W. Quong. ANTLR: A predicated-LL (k) parser generator. Software Practice and Experience, 25(7):789--810, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Servlets. http://java.sun.com/products/servlet/.Google ScholarGoogle Scholar
  16. S. Sippu and E. Soisalon-Soininen. Parsing Theory I. Springer-Verlag, 1988.Google ScholarGoogle ScholarCross RefCross Ref
  17. S. Sippu and E. Soisalon-Soininen. Parsing Theory II. Springer-Verlag, 1988.Google ScholarGoogle ScholarCross RefCross Ref
  18. S. Tregar. HTML::Template. http://html-template.sourceforge.net.Google ScholarGoogle Scholar
  19. Velocity. http://jakarta.apache.org/velocity/index.html.Google ScholarGoogle Scholar
  20. XSL style sheets.http://www.w3.org/Style/XSL/.Google ScholarGoogle Scholar

Index Terms

  1. Enforcing strict model-view separation in template engines

              Recommendations

              Comments

              Login options

              Check if you have access through your login credentials or your institution to get full access on this article.

              Sign in
              • Published in

                cover image ACM Conferences
                WWW '04: Proceedings of the 13th international conference on World Wide Web
                May 2004
                754 pages
                ISBN:158113844X
                DOI:10.1145/988672

                Copyright © 2004 ACM

                Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 17 May 2004

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • Article

                Acceptance Rates

                Overall Acceptance Rate1,899of8,196submissions,23%

                Upcoming Conference

                WWW '24
                The ACM Web Conference 2024
                May 13 - 17, 2024
                Singapore , Singapore

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader