Tags:
create new tag
view all tags

Using snippets

One of the things I've done in my current (and first) project is to create a web for snippets and other boilerplate. (I called it Lib, but the name doesn't matter.) These can be pure boilerplate, using BASEWEB and BASETOPIC to allow other webs to include a topic. These can also be parameterised, since INCLUDE now allows variables (i.e., parameters) to be passed in.

This relates to FrameLanguages, as each line that includes a topic can be thought of as a frame description.

Note: This may be similar to stuff that Micha (I think it is) has said about macros. If so, I apologise for any duplication

Examples

Easier to read topics

TWikiDocGraphics includes line after line of

| *<img src="%ATTACHURLPATH%/filter.gif" alt="Filter" title="Filter" />*  | =filter.gif= | Filter | =%<nop>ICON{filter}%= |

With the creation of a snippet

| *<img src="%PUBURL%/%BASEWEB%/%BASETOPIC%/%Icon%.gif" alt="%alt%" title="%title%" />*  | =%Icon%.gif= | %alt% | =%<nop>ICON{%Icon%}%= |
the topic becomes more readable and, more importantly, easier to add new icons to. For example, my first three lines are now
%INCLUDE{"IconRow" Icon="bubble" alt="Speech bubble" title="Speech bubble" }%
%INCLUDE{"IconRow" Icon="days"  alt="Days / Calendar" title="Days / Calendar"}%
%INCLUDE{"IconRow" Icon="download" alt="Download" title="Download"}%

Dynamic left bar

Each user in my current project has a variable ROLE defined. (In my case the roles are Teacher, Mentor, Student, Admin, and Guest.) This is related to, but not identical to, group membership, since each person has one and only one ROLE. This allows the left bar to change so that, for example, Teachers may have a "Create new assignment" link on their left bar which doesn't show up for anyone else.

My left bar is also made up of snippets, so that it includes AllActions, AllCourses, AllPeople, AllLinks, each of which in turn includes items for everyone and items for only some people. In this case I use agglutination, so that I use Actions%ROLE% which then expands to be the correct topic for the person i question

-- Contributors: MeredithLesly

Topic revision: r1 - 2006-07-20 - MeredithLesly
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.