访问被拒绝,你可能没有权限或未登录。

Rails A simple and fast JSON API template engine for Ruby on Rails

hz_qiuyuanxin · 2016年07月19日 · 最后由 pedaram 回复于 2025年06月03日 · 3675 次阅读

https://github.com/amatsuda/jb

A simpler and faster Jbuilder alternative.

我就只是分享不评论 😬

😅 比 jbuilder 好多啦!

看标题我就知道是 jb 😂

作者好高产

为什么不是更改 jbuilder,而是新建一个

看不出有什么好处

#1 楼 @luikore 为什么比 jbuilder 好多了?

json[:comments] = {
  content: @message.comments.content,
  created_at: @message.comments.created_at
}

这样的写法会变成:

"comments": [
  { "content": "Hello, world!", "created_at": "2016-06-29T20:45:28-05:00" },
  { "content": "<script>alert('Hello, world!');</script>", "created_at": "2016-06-29T20:47:28-05:00" }
]

这样真的好么。。。还嫌 Rails 中隐藏起来的知识不够多么。。。

#9 楼 @defmacro Rails 把什么知识隐藏起来了?

#10 楼 @nong 很抱歉,经过上次的讨论之后我已经懒得在这里讨论 Rails 了,没必要,因为就不会有一个理性的讨论环境。

我前面的问题写法有点问题,这里我想提出的问题是:针对这个 library,这样把实际生成的结构是 array 的语义隐藏在 comments 的类型下面,是不是个好结果。

#11 楼 @defmacro 这个地方确实让人费解

#9 楼 @defmacro 估计是 readme 里写错了

这个就是嘲讽 jbuilder 的,意思是搞那么多 DSL 不如直接上 Ruby 代码 😋 实现里什么都没写就是加个 railtie 而已 和 Rails 没什么关系

#13 楼 @luikore 啊好吧,这样,我还真没细看,喷错了😂

JBuilder is a popular gem for Ruby on Rails that serves as a powerful JSON API template engine. It allows you to create flexible Fireboy and Watergirl Game and readable JSON structures with ease. Below is a guide on how to set up and use JBuilder in your Rails application.

What makes Rails shine is its laser focus on speed and simplicity. It seamlessly integrates into the Rails ecosystem while cutting through the clutter of traditional rendering methods. Instead of fighting with bloated serializers Sprunki or hand-coded views, Rails allows developers to craft clean, declarative templates that get straight to the point. It's opinionated where it counts, and flexible when you need it to be.

需要 登录 后方可回复, 如果你还没有账号请 注册新账号