andcake / snow Goto Github PK
View Code? Open in Web Editor NEWA Coffeescript-like language that compiles to PHP.
License: Apache License 2.0
A Coffeescript-like language that compiles to PHP.
License: Apache License 2.0
I cannot use below variable. Please help.
storeId = Mage..app().getStore()
Fatal error: Uncaught exception 'Exception' with message 'Unexpected character while trying to parse T_OBJECT_TYPE_COMPARISON at line 9: storeId = Mage..app().getStore() -----------------------^' in D:\Program\Snow\snowcompiler.php:358 Stack trace: #0 D:\Program\Snow\snow.php(169): SnowCompiler->compile() #1 {main} thrown in D:\Program\Snow\snowcompiler.php on line 358
Hi, when I tried to input "class X" in my file the issue occurred as below.
Fatal error: Uncaught exception 'Exception' with message 'Unable to parse input: given input is no T_EXPRESSIONS:
class X
null' in D:\Program\Snow\snowcompiler.php:368
Stack trace:
#0 D:\Program\Snow\snow.php(169): SnowCompiler->compile()
#1 {main}
thrown in D:\Program\Snow\snowcompiler.php on line 368
I have an issue as creating new object. Please help.
Obj = new Data
Fatal error: Uncaught exception 'Exception' with message 'Unable to parse input: given input is no T_EXPRESSIONS:
In Magento __('string') (double underscores) is a pre defined function used as a translator for multiple stores with different languages, and as I know Wordpress also has a similar function. However Snow didn't recognize this or the alias of getext _() (single underscore) as a function. Please help.
Mage..helper('adminhtml').__('Latest Products')
Fatal error: Uncaught exception 'Exception' with message 'Unexpected character while trying to parse T_FNCSCALL
throw new Exceptionis compiled to
throw (new ExceptionCould you please help remove the bracket?
For example by taking the longest found chain for a target match: while walking through the language description and checking for correctness, remember how many entries of that specific rule have been matched already. Report the rule with the highest number of matched entries.
In template() function, can we use a class instead of pushing data from an array like below?
This is the way Mustache Php renders its data https://github.com/bobthecow/mustache.php
Hello {{name}} You have just won {{value}} Well, {{taxed_value}}, after taxes.
class Data { public $name = "Son"; public $value = 10000; public function taxed_value() { return $this->value - ($this->value * 0.4); } }
Add a function that fetches, evaluates templates and returns the result as a string.
I need to integrate many PHP codes into html, can Snow just parse codes between tag or ? This will make Snow much more flexible and very helpful to me.
add support for de-structuring assigments of the kind:
[a, b, , d] = <simple expression>
the left hand-side should therefore always be
[(<identifier>,)*<identifier>] =
I am using Windows so my folder path includes backslash \ and I have to use DS between url partials to prevent conflicts when deploy to production linux server. But Snow didn't recognize DS, I have tried many ways and it still doesn't work. Please help.
require_once Mage..getBaseDir('lib') % DS % 'Autoloader.php'
require_once Mage..getBaseDir('lib') + DS + 'Autoloader.php'
I need to integrate many PHP codes into html, can Snow just parse codes between tag or ? This will make Snow much more flexible and very helpful to me.
Snow's helper functions are really nice and useful. However could you please make it optional to include helpers at the top of compiled files?
if (!function_exists('in')) { function in($needle, $haystack) { switch(gettype($haystack)) { case 'string': return strpos($haystack, $needle) !== false; case 'array': return in_array($needle, $haystack); case 'integer': return $haystack - $needle >= 0; case 'object': return isset($haystack->$needle);default:return null; } } } if (!function_exists('replace')) { function replace($haystack, $pattern, $rep) { if (is_array($haystack)) { $pos = array_search($pattern, $haystack, true); if ($pos === false) return $haystack; return array_replace($haystack, Array($pos => $rep)); } $pp = '/^[^a-zA-Z0-9\\\\s].*' . str_replace('/', '\/', $pattern[0]) . '[imsxADSUXJu]*$/m'; if (preg_match($pp, $pattern)) return preg_replace($pattern, $rep, $haystack); else return str_replace($pattern, $rep, $haystack); } } if (!function_exists('template')) { function template($file, $data, $rootCore = '$data', $eval = true, $depth = 0) { $code = str_replace('\'', '\\\'', (file_exists($file.'.tpl') ? file_get_contents($file . '.tpl') : $file)); $parseVar = function($var, $root = '$data') use ($rootCore) { if (trim($var) == '.') return $root; $parts = explode('.', trim($var)); if ($parts[0] == '') $start = $rootCore; else $start = $root . '[\'' . $parts[0] . '\']'; for ($i = 1; $i < count($parts); $i++) { $start .= '[\'' . $parts[$i]. '\']'; } return $start; }; $parseVars = function($code, $root = '$data') use ($parseVar) { preg_match_all('/\{\{(?!#\/\^)((?:[^}]|\}[^}])+)\}\}/m', $code, $matches); foreach ($matches[1] as $key => $match) { $var = $parseVar($match, $root); $var = '(is_object('.$var.') && is_callable('.$var.') ? '.$var.'() : '.$var . ')'; if (trim($match) != '.') { $var = 'function_exists(\''.$match.'\') ? '.$match.'() : ' . $var; } $code = str_replace($matches[0][$key], '\' . (' . $var . ') . \'', $code); } return $code; }; $parseTpl = function($code, $root = '$data') use ($depth, $file) { preg_match_all('/\{\{>((?:[^}]|\}[^\}])+)\}\}/m', $code, $matches); foreach ($matches[1] as $key => $match) { $code = str_replace($matches[0][$key], template(dirname((file_exists($file.'.tpl') ? $file : __FILE__))."/".trim($match), null, $root, false, $depth + 1), $code); } return $code; }; preg_match_all('/\{\{(#|\^)((?:[^}]|\}[^}])+)\}\}((?:[^{]|\{[^{]|\{\{[^#\^])*)\{\{\/\2\}\}/m', $code, $matches); foreach ($matches[1] as $key => $match) { $var = $parseVar($matches[2][$key]); if ($match == '^') { $code = str_replace($matches[0][$key], '\'; if (empty('.$var.')) { $__p .= \'' . $matches[3][$key] . '\'; } $__p .= \'', $code); } else if ($match == '#') { $replacement = '\'; if (!empty('.$var.')) { if (is_array('.$var.')) foreach (' . $var . ' as $counter => $entry'.$depth.') { $__p .= \''; $replacement .= $parseVars($parseTpl($matches[3][$key], '$entry'.$depth), '$entry'.$depth) . '\'; } else { $__p .= \'' . $matches[3][$key] . '\'; }} $__p .= \''; $code = str_replace($matches[0][$key], $replacement, $code); } } $code = $parseVars($parseTpl($code, $rootCore), $rootCore); if ($eval) { $code = '$__p = \'' . $code . '\';'; eval($code); return $__p; } return $code; } }
Currently, using some of the PHP standard library functions are rather inconsistent and thus make it harder to actually use them. Those should be unified.
Some of them are:
preg_replace(pattern, replacement, haystack)
and str_replace(needle, replacement, haystack)
-> replace(haystack, needle/pattern, replacement)
in_array(needle, haystack)
, strpos(haystack, needle)
, isset(haystack[needle])
, needle <= x
, isset(haystack->needle)
-> needle in x
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.