Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #650 from IBM-Swift/updateTo5.7.0
Browse files Browse the repository at this point in the history
Release 5.7.0
  • Loading branch information
Christian Compton authored Nov 28, 2018
2 parents a34cad2 + 83e7be1 commit f9ef9d6
Show file tree
Hide file tree
Showing 25 changed files with 3,988 additions and 3,352 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ coverage.lcov
*.swp
.DS_Store
xunit.xml
.idea/
21 changes: 21 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

<a name="5.7.0"></a>
# [5.7.0](https://github.com/IBM-Swift/generator-swiftserver/compare/5.6.2...5.7.0) (2018-11-28)


### Bug Fixes

* fixed another indentation ([316dcc6](https://github.com/IBM-Swift/generator-swiftserver/commit/316dcc6))
* fixed indentation ([f01805f](https://github.com/IBM-Swift/generator-swiftserver/commit/f01805f))
* fixed indentation issues ([49bf961](https://github.com/IBM-Swift/generator-swiftserver/commit/49bf961))
* fixed indentations in Package.swift ([7e4fbaa](https://github.com/IBM-Swift/generator-swiftserver/commit/7e4fbaa))
* fixes to package.swift ([9d4eb42](https://github.com/IBM-Swift/generator-swiftserver/commit/9d4eb42))
* messing around with indentation ([eddafa4](https://github.com/IBM-Swift/generator-swiftserver/commit/eddafa4))
* Relax HeliumLogger dependency ([5731888](https://github.com/IBM-Swift/generator-swiftserver/commit/5731888))


### Features

* convert ejs to handlebars ([#621](https://github.com/IBM-Swift/generator-swiftserver/issues/621)) ([5e5c295](https://github.com/IBM-Swift/generator-swiftserver/commit/5e5c295))



<a name="5.6.2"></a>
## [5.6.2](https://github.com/IBM-Swift/generator-swiftserver/compare/5.6.1...5.6.2) (2018-11-10)

Expand Down
9 changes: 8 additions & 1 deletion app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var debug = require('debug')('generator-swiftserver:app')
var Generator = require('yeoman-generator')
var chalk = require('chalk')
var path = require('path')

var Handlebars = require('../lib/handlebars.js')
var actions = require('../lib/actions')
var helpers = require('../lib/helpers')
var validateDirName = helpers.validateDirName
Expand Down Expand Up @@ -139,6 +139,13 @@ module.exports = Generator.extend({
}
},

_writeHandlebarsFile: function (templateFile, destinationFile, data) {
var template = this.fs.read(this.templatePath(templateFile))
var compiledTemplate = Handlebars.compile(template)
var output = compiledTemplate(data)
this.fs.write(this.destinationPath(destinationFile), output)
},

initSpec: function () {
function isTrue (value) {
return (value === true || value === 'true')
Expand Down
36 changes: 36 additions & 0 deletions lib/handlebars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
© Copyright IBM Corp. 2017, 2018
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// module for Handlebars helpers

'use strict'

const Handlebars = require('handlebars')

Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) {
switch (operator) {
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this)
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this)
default:
return options.inverse(this)
}
})

Handlebars.registerHelper('settingID', function (propertyInfos, model) {
var args = (['id: newId'].concat(propertyInfos.filter((info) => info.name !== 'id').map((info) => `${info.name}: ${info.name}`))).join(', ')
return ` return ${model.classname}(${args})`
})

module.exports = Handlebars
16 changes: 16 additions & 0 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,22 @@ exports.ifequal = function (arg1, arg2, options) {
return (arg1 === arg2) ? options.fn(this) : options.inverse(this)
}

exports.ifCond = function (v1, operator, v2, options) {
switch (operator) {
case '===':
return (v1 === v2) ? options.fn(this) : options.inverse(this)
case '>':
return (v1 > v2) ? options.fn(this) : options.inverse(this)
default:
return options.inverse(this)
}
}

exports.settingID = function (propertyInfos, model) {
var args = (['id: newId'].concat(propertyInfos.filter((info) => info.name !== 'id').map((info) => `${info.name}: ${info.name}`))).join(', ')
return ` return ${model.classname}(${args})`
}

exports.swiftFromSwaggerType = function (swaggertype) {
// return a Swift type based on a swagger type. Format is ignored and
// if a translated type is not found, the original type is used.
Expand Down
Loading

0 comments on commit f9ef9d6

Please sign in to comment.