(written in an oldfashioned way)
This is a fork of mulle-kybernetik/MulleScion tailored for use in mulle-sde projects
Release Version | Release Notes |
---|---|
RELEASENOTES |
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];
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".
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>
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).
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...
Use mulle-sde to add MulleScion to your project:
mulle-sde add github:MulleWeb/MulleScion
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
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
All platforms and compilers supported by mulle-c11.
Nat! for Mulle kybernetiK
@hons82 (Hannes)