GithubHelp home page GithubHelp logo

node-blade's People

Contributors

bminer avatar codelenny avatar dab0bby avatar jessetane avatar martindale avatar mhuebert avatar sbking avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-blade's Issues

Ability to change behavior of `render`

Rendering a block always appends the rendered content to the end of a block. Maybe create the ability to prepend and replace, as well?

Proposed Syntax:

render append block(args)
render replace block(args)
render prepend block(args)

render block(args) will be the same as render append block(args).

Build a test suite

Probably build a test library that does the following:

1.) Read data from a Blade template (i.e. /test/123.blade)
2.) Read options data, including locals to be passed to the view (i.e. /test/123.js)
3a.) If the output HTML exists (i.e. /test/123.html), then compare it with rendered output; otherwise,
3b.) Write the HTML output (i.e. /test/123.html) and prompt the user to review the output for errors.

3b allows one to easily generate new test cases. :)

Newline Issue

Newlines are prepended to text nodes or filtered_text nodes when the last node was one of the same. Unfortunately, this feature is not working correctly. Consider this example:

p this is
  | a test
  span of newlines
  | . Cool.

renders as:

<p>this is
a test<span>
of newlines</span>. Cool.</p>

instead of

<p>this is
a test<span>of newlines</span>. Cool.</p>

Minor difference, but still a bug.

how to wrap a template inside a template?

like if i have a outside teamplte

chunk template
    table.data-users
        thead
        tbody

and a user loop template

chunk users(user)
    tr
        td= user.name
        td= user.sex
        td= user.age

how to combine above code to render together

$('.data-users tbody').html( Meteor.ui.render( Template.staffs ) );

Support Includes in Functions, Blocks, and Chunks

File includes should be permitted in functions, blocks, and chunks. This can be fixed by making each function definition, chunk definition, block definition, block modification, or block render statement asynchronous.

For example, a file include within a block modifier:

append foobar(header, footer)
    h1=header
    include "foobar"
    h1=footer
h1 Finally

compiles to:

//Standard template init code goes here... including try, with blocks
//__.line, __.col, __.base, __.rel removed for brevity
__.cb = cb;
cb = function(err, html, info) {if (!info.inc) info.r.done(info); __.cb.apply(this, arguments);};
__.r.blockMod("a", "foobar", __, function(__, cb, header, footer) {
    __.push('<h1','>',header,'</h1>');
    __.r.include('foobar', __, function(err) {
        __.push('<h1','>',footer,'</h1>');
        cb(); //This closing thingy was put here by the compiler in the blockMod function, as instructed by the include.
    }); //This closing thingy was put here by the compiler in the blockMod function, as instructed by the include.
}, function() {
    __.push('<h1','>','Finally','</h1>');
    if(!__.inc) __.r.done(__); cb(); //This closing thingy was put here by the compiler when finishing up
}); //This closing thingy was put here by the compiler when finishing up, as instructed by the blockMod

As per the comment listed in the code above, the compiler needs to keep track of "closing snippets" that were added by child nodes, as appropriate. When the compiler is done with all of the nodes, it will inject any remaining "closing snippets". The final cb() call will be injected just before the final "closing snippets."

The runtime needs to capture errors more intelligently, as well. There is no sense in putting try, catch blocks in the template itself, except for the initial try, catch, as it is used to pass errors to the callback instead of the caller.

Just as personal reminders:

Templates use try, catch blocks to capture additional error information. The last line of the try block is cb(null, __.join(""), __);
If a runtime error occurs within a template, the catch block will do this: return cb(__.r.rethrow(err, __) );

If a runtime error occurs within an included template, the runtime is responsible for
passing it to the includer's callback like this:
cb(__.r.rethrow(err, __) );
BUT, the __ should be in the context of the includer (i.e. proper line number, filename, etc.)

In addition, the runtime should expect the include callback function to throw an error.
It should catch these errors and pass to the includer's callback function.

The same is true of callbacks to function calls, callbacks after block modifiers, etc. The
runtime must expect the callback function to throw an error and then rethrow it properly.

/* Block comments */

C++ style block comments should be supported, starting with /* and ending with */. These comments still need to be processed by the parser because text blocks might contain /* a comment */, which should still be rendered, if needed. Therefore, block comments will be a regular node from the parser's perspective.

/* this comment will not output into the template */
/** this comment will output into the template */

will render to:

<!--this comment will output into the template-->

Live UI - Model validation

Add the ability to setup data validation functions for model properties like so:

model.validation.firstName = function(input) {
    //Return true to be valid; false to be invalid
    //return input.length > 0;
    //Can also return an Object for more options
    return {
        "valid": input.length > 0,
        "value": input.trim()
    };
};
//Now set firstName
model.set("firstName", "Blake  ");
//Now check to see if the input was valid
model.valid("firstName"); //true
//Now let's check what value was set...
model.peek("firstName") // "Blake"

Text string interpolation

Look for variable names in a string of text for interpolation. Do it just like Jade... #{var_name} will be replaced with the contents of var_name.

Benchmarks

Blade needs some benchmarks:

  • Compile time with caching
  • Compile time without caching
  • Renders per second on the client without caching
  • Renders per second on the client with caching
  • Renders per second on the server without caching
  • Renders per second on the server with caching
  • ...any others I forgot

If anyone can tackle this, I'd greatly appreciate it!

Build express middleware to deliver compiled client-side templates

Build express middleware to deliver compiled client-side templates. For example, you can set a mount point (i.e. "/views") and any GET request to "/views/view123.blade" will cause the Express middleware to compile the blade template and deliver the JavaScript code to the browser. No client-side caching of templates would be required; this would be handled automatically by the server (i.e. using 304 Not Modified weak caching or Expires headers and strong caching).

Code within an attribute value cannot contain any spaces, even for quoted strings

Perhaps reconsider the syntax. Separating attributes with whitespace is nice, but it limits what your code looks like. Although probably rare, you may want to do:

div(attr=foo+" bar")

which is not allowed because the attribute value code contains a space. Maybe if the parser was smart enough to detect quoted strings within attribute value code?

postinstall.sh prevents install on Windows

When I tried to install blade using node, I got this error message (with cmd and MSYS bash):

> ./postinstall.sh

'.' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! [email protected] postinstall: `./postinstall.sh`
npm ERR! `cmd "/c" "./postinstall.sh"` failed with 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is most likely a problem with the blade package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./postinstall.sh
npm ERR! You can get their info via:
npm ERR!     npm owner ls blade
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Windows_NT 6.0.6002
npm ERR! command "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "blade"
npm ERR! cwd c:\Program Files\nodejs
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.24
npm ERR! code ELIFECYCLE
npm ERR! message [email protected] postinstall: `./postinstall.sh`
npm ERR! message `cmd "/c" "./postinstall.sh"` failed with 1
npm ERR! errno {}

npm ERR! Error: EPERM, open 'c:\Program Files\nodejs\npm-debug.log'
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR!
npm ERR! System Windows_NT 6.0.6002
npm ERR! command "c:\\Program Files\\nodejs\\node.exe" "c:\\Program Files\\nodej
s\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "blade"
npm ERR! cwd c:\Program Files\nodejs
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.24
npm ERR! path c:\Program Files\nodejs\npm-debug.log
npm ERR! code EPERM
npm ERR! message EPERM, open 'c:\Program Files\nodejs\npm-debug.log'
npm ERR! errno {}
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     c:\Program Files\nodejs\npm-debug.log
npm not ok
npm not ok

I had to open up the .tgz archive that npm downloaded and remove the postinstall script hook before it would install blade.

Functions do not work

Blade functions are not yet implemented. Follow the spec outlined in the README file to implement these.

Better Reporting for Syntax Errors

If there is a problem with the Blade compiler, or more likely, if there is a syntax error with the JavaScript code in a template, Node.js will not provide any line number or other information about the error. At the time of this writing, this is a limitation of the Google V8 engine; it cannot report line numbers in evaled JavaScript code.

Related upstream issues:

Node: nodejs/node-v0.x-archive#229, nodejs/node-v0.x-archive#2734
Google V8: http://code.google.com/p/v8/issues/detail?id=1914 (now somewhat fixed)
https://code.google.com/p/v8/issues/detail?id=1281
https://code.google.com/p/v8/issues/detail?id=2589

Progress is being made to improve this.

Fewer __.push() calls in templates for code optimization

__.push(a);
__.push(b);
__.push(c);

can be re-written as:

__.push(a,b,c);

which can make compiled templates much smaller - 9 or 10 characters per push. To implement, I was thinking about having a flag in the compiler inPush. When set, we are in the middle of a push(...) call. Whenever we need to get out, we need to append a );. Whenever, we need to get inside one, we need to append __.push(. Should be simple enough.

Support for inline coffeescript

Can we get support to interpret javascript portions as coffeescript? Maybe automatically interpret .bladec files as coffeescript-backed blade files?

Remove `Meteor.startup` function wrapper from generated templates?

Templates generated by Blade and the Blade smart package are wrapped with Meteor.startup(function() {...});

This might be pointless at best and potentially harmful at worst. Need to look into the documenation for Meteor.startup to see if this is necessary. I think this is what Handlebars does? I dunno.

Blade-generated id's may conflict

Modify the runtime so that Blade-generated id attributes do not conflict with elements that already exists on the webpage (i.e. check to see if it exists first by using document.getElementById.

Crash using attributes and whitespacing

A temple with: .card(style="left:0px")
will not crash but if between = and the first " a space exists like: .card(style= "left:0px")
then the app will crash.

Also a more complicated construction like: .card(style="left:"+card.left+"px;top:"+card.top+"px")
will crash:

    SyntaxError: Parser error: Expected child node or newline but "(" found.
        at /Users/michel/meteor/gaido/views/board.blade:6:7

Meteor integration, howto

I have installed blade within my meteor environment, but don't know how to use it and or how to set it up.

As an "hello world" I have to next template file:
views/hello.blade:

html
  head
  body
    p Hello world!

Now if I kick off meteor I get the next errors:

Errors prevented startup:

Exception while bundling application:
TypeError: Cannot call method 'toString' of undefined
    at /usr/lib/meteor/packages/blade/package.js:30:59
    at /usr/lib/meteor/lib/node_modules/blade/lib/blade.js:37:19
    at Compiler.compile (/usr/lib/meteor/lib/node_modules/blade/lib/compiler.js:90:10)
    at compile (/usr/lib/meteor/lib/node_modules/blade/lib/blade.js:36:12)
    at Object.compileFile (/usr/lib/meteor/lib/node_modules/blade/lib/blade.js:56:3)
    at /usr/lib/meteor/packages/blade/package.js:18:8
    at [object Object].add_file (/usr/lib/meteor/app/lib/bundler.js:196:5)
    at /usr/lib/meteor/app/lib/bundler.js:97:16
    at Array.forEach (native)
    at Function.<anonymous> (/usr/lib/meteor/app/lib/third/underscore.js:76:11)
 Your application is crashing. Waiting for file change.

Somehow tmpl is undefined??

Create :javascript filter

Create a :javascript filter similar to :coffeescript. Perhaps use UglifyJS for minification on :javascript and :coffeescript?

Can't make it work with meteor.

i had this step done
ln -s /path/to/blade/meteor /path/to/meteor/packages/blade

and when i execute meteor add blade

it just tells me

bogon:app crapthings$ meteor add blade

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Cannot find module 'blade'
at Function._resolveFilename (module.js:332:11)
at Function._load (module.js:279:25)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at /usr/local/meteor/packages/blade/package.js:2:13
at [object Object].init_from_library (/usr/local/meteor/app/lib/packages.js:104:5)
at Object.get (/usr/local/meteor/app/lib/packages.js:222:11)
at /usr/local/meteor/app/lib/packages.js:273:30
at Array.forEach (native)
at Function. (/usr/local/meteor/app/lib/third/underscore.js:76:11)

Finish client runtime file

Need to finish client runtime and distribute *.js files. Possibly automate the build process of the client runtime (minify the code, etc.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.