Loading ...
Sorry, an error occurred while loading the content.

4977[Cheetahtemplate-discuss] indentation

Expand Messages
  • Dov Feldstern
    Aug 23, 2011
    • 0 Attachment
      Hi!

      Say I have the following template:

      void foo(int a)
      {
      int i = 0;
      $do_something
      for (i = 0; i < 10; i++) {
      $do_something
      }
      }

      This works just fine if $do_something consists of a single line;
      however, if $do_something consists of multiple lines, then I have a
      problem with the indentation, depending on what exactly the
      placeholder itself looks like:

      1) if the placeholder does not include any indentation itself, then
      the first line is indented correctly (because the indentation appears
      outside of the placeholder), but the rest are not;
      2) so, I could have the placeholder already include the indentation,
      but this has two problems:
      (a) the placeholder would have to appear unindented in the template,
      which is not pretty; and
      (b) more importantly, the placeholder may appear in multiple places,
      each requiring different indentation.

      I'm aware of the "undocumented" #indent function (as documented in the
      TODO), and by playing around with it (using cheetah 2.4.4) I see that
      some of the options work, and am able to get the indentation correct.
      However, I'm a little wary of using undocumented features which may be
      in flux; and also, the resulting templates are much more verbose than
      I would like (too many #indent commands).

      Ideally --- what seems to me like the natural solution (without having
      considered use-cases that are different than mine, and without having
      looked at the implementation at all ;) ) --- I would like the
      indentation of a placeholder to be added to each line of the
      placeholder's contents. Is that possible / difficult to implement /
      inappropriate for other use-cases? Does anyone have any other
      suggestions for achieving what I want?

      Thanks!
      Dov

      ------------------------------------------------------------------------------
      Get a FREE DOWNLOAD! and learn more about uberSVN rich system,
      user administration capabilities and model configuration. Take
      the hassle out of deploying and managing Subversion and the
      tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss