Nov 18, 2015; 09:57
Jolle Carlestam
jc_include now supports LassoApps
I’ve updated jc_include to now also support including files from compiled LassoApps.
The reason jc_include exists is because it, in contrast to Lassos regular include_file, allows you to send local variables to the include and have them accessible inside the include
Here are some examples on how it can look:
This has always been possible since the original implementation:
jc_include(file('includetest.inc'), -name = 'brad', -country = 'UK’)
With includetest.inc looking like this:
[
#name
’<br>'
#country
]
The result will be:
brad
UK
With the new version you can call files that are part of a compiled LassoApp. The construct of the Lasso specific code inside the included LassoApp file differs depending on if you call it as lasso extension or html. The html is easiest.
First the lasso extension version:
jc_include(
lassoapp_include('/myapp/mytest', 'lasso'),
'/myapp/mytest.lasso',
-title = 'Hello World',
-content = 'Here be content’
)
The include file needs to use [] syntax for any code that’s to be processed after the include and start with a [no_square_brackets].
Any Lasso code inside Lassoscript syntax, as in <?LassoScript code ?> will be processed before the file is included and not have access to the provided params.
Content of mytest.lasso:
[no_square_brackets]<!DOCTYPE html>
<html lang="en">
<head>
<title>[#title]</title>
</head>
<body>
[#content]
</body>
</html>
Personally I prefer this way:
jc_include(
lassoapp_include('/myapp/mytest', 'html'),
'/myapp/mytest.html',
-title = 'Hello World',
-content = 'Here be content’
)
Content of mytest.html can in fact be anything and not contain any html at all. Including it as a html file is only a directive to Lasso to not preprocess any of the content and instead send it raw to jc_include.
<!DOCTYPE html>
<html lang="en">
<head>
<title>[#title]</title>
</head>
<body>
[#content]
</body>
</html>
I use jc_include a lot and find it very convenient. It makes it possible to skip vars entirely and instead use locals. Giving much better control over your dynamic content. The main use for me is of course to include html templates at the end of processing a request.
You can find the latest incarnation at
https://gist.github.com/jolle-c/95847fcd568d63d09aed
While there, take the opportunity to check out some of the other gists I have published. Most of them are very useful. :-)
HDB
Jolle
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso Lasso@lists.lassosoft.com
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Nov 18, 2015; 10:02
Jolle Carlestam
Re: jc_include now supports LassoApps