+2

I have been trying to use textastic with less (lesscss.org) and I have been unable to get it to preview the HTML file correctly.

Fraser Graham 13 years ago updated by Pedro Grilo 13 years ago 14
I have an HTML file that includes a .less file and then the JavaScript less compiler. When I preview with textastic, Iit appears that none of the JavaScript has executed.

Are there limits on js execution in the preview?
I think perhaps this is related to cross domain resources., a .less file might not be able to be sources locally.
If you send me an example, I can try to reproduce it on my iPad.
-1
You can try the basic samples from lesscss.org. I have the same problems with just their basic setup.

I doubt this is a textastic bug actually. More than likely a limitation of the uiwebview.
The basic sample works for me as described in my last comment.
I would love to see this fixed.
Unfortunately it is a Textastic limitation, since it works just fine with Koder and with iFile webview.
I've just tried it out and it works fine for me:


test.html:

<!DOCTYPE HTML>

<html>
<head>
<meta charset="utf-8">
<title>Less Test</title>
<link rel="stylesheet/less" href="style.less" type="text/css" />
<script src="lesscss.js" type="text/javascript"></script>
</head>
<body>
This is a test for lesscss. 
</body>
</html>

style.less:

@color: blue;

body {
color: @color;
}

I've put the lesscss.js in the same folder as text.html and style.less. This resulted in blue body text.

Thank you for your support!
I'm using Bootstrap from twitter and it works in Koder, and any webkitview app I've tested, but fails on my favorite editor (Textastic).
Please try it with the Bootstrap files:
https://github.com/twitter/bootstrap/
Or using the h5bp initializer with bootstrap, for fast checking: https://github.com/verekia/initializr-bootstrap/

I would love to see it working, I can compile it to css on the iPad ( with nodejs and Prompt) but live previewing quick changes is essential.
TY
The problem is in the "loadStyleSheet" function of LESS: https://github.com/cloudhead/less.js/blob/master/dist/less-1.2.2.js#L3079


Textastic uses the custom "preview://" protocol, not "file://". This is needed to work around a caching but in iOS 5. 


So if you the change regular expression in this line:

if (! /^(https?|file):/.test(href)) {

to

if (! /^(https?|file|preview):/.test(href)) {

then it works for me in Textastic.

+1
Note: it's just the @import directive that doesn't work for local files. If you enter a complete url like
@import "http://www.example.com/test.less"

then it does work without modification.

Unfortunately, there is not much I can do about it. This would need to be changed in LESS, so that it doesn't hard-code supported schemas but checks if the path starts with <schema>:/

I will make that suggestion to the dev.
Thank you again! Sincerely.
Thank you for so promptly take the time, especially on a Sunday, to have a look into this.
Consider it fixed! :)
But, btw and a little off topic, could this custom schema (preview://) be the cause I my unccessful tries at loading firebug lite? Just cossed my mind..
TY
Possibly. But I've added support for Firebug Lite in Textastic 4.0. I'm going to submit this version to Apple today.
Awesome! :D
Can't wait! Code completion and firebug integration will streamline the workflow on my side.