Skip to content

🌱 A modern template engine for mulle-objc (library)

License

Notifications You must be signed in to change notification settings

MulleWeb/MulleScion

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MulleScion

🌱 A modern template engine for Objective C

(written in an oldfashioned way)

This is a fork of mulle-kybernetik/MulleScion tailored for use in mulle-sde projects

Release Version Release Notes
Mulle kybernetiK tag Build Status RELEASENOTES

Example

Here is a simple example, where ObjC code is embedded in a template:

<html>
   <!-- rendered by {{ [[NSProcessInfo processInfo] processName] }} on
        {{ [NSDate date] }} -->
   <body>
     {% for item in [NSTimeZone knownTimeZoneNames] %}
         {% if item#.isFirst %}
         <table>
            <tr><th>TimeZone</th></tr>
         {% endif %}
            <tr><td>{{ item }}</td></tr>
         {% if item#.isLast %}
         </table>
         {% endif %}
      {% else %}
         Sorry, no timezone info available.
      {% endfor %}
   </body>
</html>

Using MulleScion the creation of a string from your object using a template file is as easy as:

   NSString  *output;

   output = [MulleScionTemplate descriptionWithTemplateFile:@"test.scion"
                                                 dataSource:self];

Info

This is the general architecture of MulleScion

MulleScion is happily used in a commercial project and has gone through enough iterations to pronounce it "ready for production".

HTML PREPROCESSOR

There is a companion project MulleScionHTMLPreprocessor that uses HTML like tags, to make the template easier to reformat in HTML editors:

<html>
  <!-- rendered by mulle-scion on
        2024-12-11T16:48:52Z -->
  <body>
    <for item in [NSTimeZone knownTimeZoneNames]>
      <if item#.isFirst>
        <table>
          <tr><th>TimeZone</th></tr>
      </if>
        <tr><td></td></tr>
      <if item#.isLast>
        </table>
      </if>
    <else/>
      Sorry, no timezone info available.
    </for>
  </body>
</html>

Documentation

The documentation is contained in a companion project mulle-scion.

MulleScion is very similar to TWIG, so you can glean much of relevance from http://twig.sensiolabs.org. If you see a feature in TWIG but don't see it in the tests file, it's likely not there (but it's probably easily achieved some other way (using a define or a macro or an ObjC category on NSString).

LIMITATIONS

Because you can execute arbitrary ObjC methods, and have access to Key Value Coding, MulleScion can pretty much do anything. MulleScion uses NSInvocation for method calls. That means there will be problems with variable arguments methods. Be wary of anything using structs and C-Arrays and C-strings, although MulleScion tries to be as helpful as possible.

MulleScion does not do arithmetic or bitwise logic, quite on purpose.

MulleScion && and || have no operator precedence, use parentheses.

MulleScion doesn't prevent you from trying stupid things.

The documentation is not very good, actually it is just more or less a collection of test cases with comments...

You are here

Overview

Add

Use mulle-sde to add MulleScion to your project:

mulle-sde add github:MulleWeb/MulleScion

Install

Install with mulle-sde

Use mulle-sde to build and install MulleScion and all dependencies:

mulle-sde install --prefix /usr/local \
   https://github.com//MulleScion/archive/latest.tar.gz

Manual Installation

Install the requirements:

Requirements Description
MulleFoundation πŸ’ Umbrella library for the MulleFoundation
MulleObjCHTTPFoundation 🎫 HTTP and HTML utility methods and classes for mulle-objc
MulleObjCInetOSFoundation πŸ“ πŸ’» OS specific extensions to NSHost and NSURL
mulle-objc-list πŸ“’ Lists mulle-objc runtime information contained in executables.

Download the latest tar or zip archive and unpack it.

Install MulleScion into /usr/local with cmake:

cmake -B build \
      -DCMAKE_INSTALL_PREFIX=/usr/local \
      -DCMAKE_PREFIX_PATH=/usr/local \
      -DCMAKE_BUILD_TYPE=Release &&
cmake --build build --config Release &&
cmake --install build --config Release

Platforms and Compilers

All platforms and compilers supported by mulle-c11.

Author

Nat! for Mulle kybernetiK
@hons82 (Hannes)

About

🌱 A modern template engine for mulle-objc (library)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 92.5%
  • C 7.3%
  • CMake 0.2%