Skip to content

Commit

Permalink
improvement: use Jet brains mono for pretty print font
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Apr 14, 2020
1 parent eb3a492 commit fdab49e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
11 changes: 10 additions & 1 deletion example/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ edge.mount(join(__dirname, 'views'))

createServer((_req, res) => {
res.writeHead(200, { 'content-type': 'text/html' })
res.end(edge.render('welcome', { username: 'virk', age: null }))
res.end(edge.render('welcome', {
user: {
username: 'virk',
email: 'virk@adonisjs.com',
isAdmin: true,
lastLoginAt: null,
createdAt: new Date(),
updatedAt: new Date(),
},
}))
}).listen(3000, () => {
console.log('Listening on 127.0.0.1:3000')
})
18 changes: 14 additions & 4 deletions src/Edge/globals/PrettyPrint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,25 @@ export class PrettyPrint {
null: 'color: rgb(255, 203, 139);',
function: 'color: rgb(255, 203, 139);',
pre: `
padding: 10px 30px;
padding: 30px 25px;
background-color: rgb(6, 21, 38);
color: rgb(214, 222, 235);
font-family: Menlo, Monaco, monospace;
border-radius: 6px;
font-family: JetBrains Mono, Menlo, Monaco, monospace;
font-size: 14px;
line-height: 1.4;
text-align: left;
`,
}

/**
* Return a boolean telling if the variable name is a
* standard global
*/
private isStandardGlobal (name) {
return ['inspect', 'truncate', 'excerpt', 'safe'].includes(name)
}

/**
* Encode html
*/
Expand Down Expand Up @@ -77,8 +87,8 @@ export class PrettyPrint {
* Pretty print by converting the value to JSON string first
*/
public print (value: any) {
const json = JSON.stringify(value, function (key, keyValue) {
if (['safe', 'inspect'].includes(key)) {
const json = JSON.stringify(value, (key, keyValue) => {
if (this.isStandardGlobal(key)) {
return undefined
}

Expand Down

0 comments on commit fdab49e

Please sign in to comment.