Giter Club home page Giter Club logo

bliss's Introduction

bliss

A template engine for Node.js, inspired by Microsoft Razor and Play! Framework template engines.

I became hooked on using Play! framework's Scala templates, which was inspired by Razor templates. I liked it so much, that I found I really wanted to use something similar on Node.js.

Details

See wiki for details on use and syntax.

See issues for details on bugs and features.

bliss's People

Contributors

calebeby avatar cstivers78 avatar dizlexik avatar junosuarez avatar rdolgushin 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

Watchers

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

bliss's Issues

HTMLminify

HTML minifier get error due to <products

// Not worked :(
@for(var p=0; p<products.length; p++) {
  @{product = products[p]} 
  <li>@product.name </li>
}
// Worked! :)
@for(var p=products.length - 1; p>0; p--) {
  @{product = products[p]}
  <li>@product.name </li>
}

Newer node engine support

I get the following warning when installing:

npm WARN engine [email protected]: wanted: {"node":">= 0.5.0 < 0.7.0"} (current: {"node":"v0.8.15","npm":"1.2.0"})

However, it seems to be running without issue on:

{ http_parser: '1.0',
  node: '0.8.15',
  v8: '3.11.10.25',
  ares: '1.7.5-DEV',
  uv: '0.8',
  zlib: '1.2.3',
  openssl: '1.0.0f' }

Any chance you could update the version specified in package.json?

Unable to use composing layout

I'm using express js and I'm trying to use composing layout, when the bliss is rendering the template is looking for the layout its own folder instead the layout path, so I'm always getting "Error: ENOENT, no such file or directory 'layout.html'".

this is the code:

layout.html
the same as bliss sample layout

test.html
@function body(){
//Hello!!
}
@render('layout',"title", body)

test.js
bliss.render("test.html",{});

I got everything working by changing the line 64 in bliss.js: sending the filepath instead of filename to the compileFile method

template = self.compileFile(filepath, options);

I'm just testing bliss, I really don't know if I'm doing something wrong or there is an issue in the bliss,js code.

forEach

Hello. Thank you for lib!

<ul> 
// This is not worked!
@products.forEach(function(product){
  <li>@product.name</li>
})

// This is worked!
@for(var p=0; p<products.length; p++) {
  @{product = products[p]} ?>
  <li>@product.name </li>
}
</ul>

Express.js view engine

Hi,

I'm wondering if you could implement and provide a version of your template system as a Express.js view engine? Seamless partials and layout would be very nice, integrated some how with the internal Express.js API.

Best regards,
André.

forEach -not worked

Hello. Thank you for lib!

<ul> 
// This is not worked!
@products.forEach(function(product){
  <li>@product.name</li>
})

// This is worked!
@for(var p=0; p<products.length; p++) {
  @{product = products[p]} ?>
  <li>@product.name </li>
}
</ul>

Unable to compose templates.

The following issue was reported via email:

Hey Chris,

I just started using your template engine in my project, however i'm
having trouble calling the render function from with in a view.

I have two views in my project one called "index" and the other called
"sitelayout"

I'm calling render in my index view to pull in the sitelayout and it
crashes within bliss.js.

I've attached the views and error i'm getting.

Thanks a lot for your help

Cheers

-Sai

external functions?

Is it possible to include functions defined in another file?

index

@render('globals')

@myCustomFunction ()

globals

@function myCustomFunction (){
stuff
}

myCustomFunction is not defined.

t would be awesome if there was a @require or similiar

Add support for escaping template values

I really like the syntax for the Bliss templates. The only thing keeping me from using it is that it doesn't HTML escape template values. This makes it very difficult to to prevent XSS issues. Please add support for doing this by default.

Also, if you do add support for this, make sure you provide a way to bypass the escaping because sometimes you do need to put raw values in templates.

Thanks

Update for node 8 to 11

The package.json is limiting bliss use for node between 5 and 7, but I can't see any problem using it with node 8, 9, 10, 11. Could we update it please?

Map javascript ouput to template input

I really want this, but I do not really need it (yet).

To improve debugging abilities, I need to map the lines of compiled template (javascript) to the lines of the source file. So, when an error is thrown from within the template, it could contain the line number from where the error originates. Node/V8 is not helpful because it tells me it has no clue where the errors originate from.

So for now, I have to look at the compiled output of the template and figure it out... sometimes paste the output into a .js file and run it in node.

Incorrect parenthesis matching

The following examples will cause bliss to incorrectly tokenize due to the parenthesis matching being based on balancing.

Hello from Bliss @(":)")

And when using a parent layout

@render('layout', function() {

  Hello from Bliss :)

})

This probably also applies to } when parsing the function and perhaps even ].

Not sure how much can be done to solve this without needing to understand more javascript syntax, or restructuring the tokenizer.

bliss.render hangs and never exist

Hello,
Thank you for the great module! I've been using it for a long time without any issue but recently I've updated my node.js version to v9.2.0 (on MAC) and now bliss.render hangs and never exits.
Please let me know what additional info may I provide to resolve this issue.

Thank you

Documentation example for global vars

It might be worth it to outline specifically that you can have an example context... the below allowing one to extend viewbag in the view, then when rendering down to the layout, it can be utilized...

context: { 
  viewbag:{} 
}

which should allow you to attach parameters to the viewbag, such as viewbag.title, that will be carried out to a layout. Which will be somewhat similar to what you may be used to...

Another suggestion of convention would be to pass (regions/model) as a single argument... This way certain conventions can be extended while keeping the same signature... such as the (error,data,callback) signature in a lot of node itself... if a layout gets (regions) and the target view or partial gets a (model), while this would take a bit more effort to utilize, it's just a thought.

layout.cs.html

@(regions)
...
  @regions.side()
...
  @regions.body()
...

index.cs.html

@(model)
@function side() { ...}
@function body() {...}
@render('layout',{side:side,body:body})

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.