Fragments

A tool for diff-based templating / fragmentation control
Download

Fragments Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Matt Chisholm
  • Publisher web site:
  • http://devsuki.com/pottymouth/

Fragments Tags


Fragments Description

Fragments is a Python module that uses concepts from version control to replace many uses of templating languages. Instead of a templating language, it provides diff-based templating; instead of revision control, it provides "fragmentation control".Fragments is a DRY (Don't Repeat Yourself) violation manager; it is a Multiple Source of Truth engine.What is diff-based templating?------------------------------Generating HTML with templating languages is difficult because templating languages often have two semi-incompatible purposes. The first purpose is managing common HTML elements & structure: headers, sidebars, and footers; across multiple templates. This is sometimes called page "inheritance". The second purpose is to perform idiosyncratic display logic on data coming from another source. When these two purposes can be separated, templates can be much simpler.Fragments manages this first purpose, common HTML elements and structure, with diff and merge algorithms. The actual display logic is left to your application, or to a templating language whose templates are themselves managed by Fragments.What is fragmentation control?------------------------------The machinery to manage common and different code fragments across multiple versions of _a single file_ already exists in modern version control systems. Fragments adapts these tools to manage common and different versions of _several different files_.Each file is in effect its own "branch", and whenever you modify a file ("branch") you can apply ("merge") that change into whichever other files ("branches") you choose. In this sense Fragments is a different kind of "source control"--rather than controlling versions/revisions over time, it controls fragments across many files that all exist simultaneously. Hence the term "fragmentation control".As I am a linguist, I have to point out that the distinction between (http://en.wikipedia.org/wiki/Synchronic_analysis) and (http://en.wikipedia.org/wiki/Diachronics) Linguistics gave me this idea in the first place.How does it work?The merge algorithm is a version of Precise Codeville Merge modified to support cherry-picking. Precise Codeville Merge was chosen because it supports accidental clean merges and convergence. That is, if two files are independently modified in the same way, they merge together cleanly. This makes adding new files easy; use Fragment's `fork` command to create a new file based on other files (or just `cp` one of your files), change it as desired, and commit it. Subsequent changes to any un-modified, common sections, in that file or in its siblings, will be applicable across the rest of the repository.Like version control, you run Fragments on the command line each time you make a change to your HTML, not before each page render.Product's homepage


Fragments Related Software